Skip to content

Instantly share code, notes, and snippets.

@martin-langhoff
Created September 28, 2016 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martin-langhoff/299d98d452b8b17e130ba80e62001df5 to your computer and use it in GitHub Desktop.
Save martin-langhoff/299d98d452b8b17e130ba80e62001df5 to your computer and use it in GitHub Desktop.
defmodule Common.MixTools do
# WE
def get_version do
try do
:ets.new(:version_cache, [:named_table, :set, :public])
rescue
[ArgumentError] -> nil
end
case :ets.lookup(:version_cache, 'version') do
[] ->
val = get_version_int()
:ets.insert(:version_cache, { 'version', val })
val
[{ 'version', val }] ->
val
end
end
defp get_version_int do
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment