I have the following code in elixir:
def get_trackerid(imei) do
client = get_new_client()
{:ok, result} = :cqerl.run_query(client, "SELECT * FROM trackers_by_imei where imei = \'#{imei}\';")
row = :cqerl.all_rows(result)
end
Now, now many functions are calling get_trackerid function and everytime the function is called, a call to database is made.
Is there a way to write a function in elixir such the result is stored in a local variable. So, when the next time trackerid for the same imei is requested, I can get the data from the local variable itself.
I think there is no concept of global variable in elixir, so that is not an option, right?