Skip to content

Instantly share code, notes, and snippets.

@etrepum
Created January 17, 2012 16:30
Show Gist options
  • Save etrepum/1627358 to your computer and use it in GitHub Desktop.
Save etrepum/1627358 to your computer and use it in GitHub Desktop.
table_increment/3
table_increment(Table, Key, Value) ->
try
ets:update_counter(Table, Key, Value)
catch
error:badarg ->
ets:insert_new(Table, {Key, 0}),
ets:update_counter(Table, Key, Value)
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment