Skip to content

Instantly share code, notes, and snippets.

@rbotzer
Last active November 2, 2019 01:22
Show Gist options
  • Save rbotzer/616634ba7399fca0f5a2e2658085dd2c to your computer and use it in GitHub Desktop.
Save rbotzer/616634ba7399fca0f5a2e2658085dd2c to your computer and use it in GitHub Desktop.
Give an award once and only once
# add an award icon to a specific player ("CFO") where awards have a type
# and a count, some awards can be given once, and some more than once
ctx = [
ctxh.cdt_ctx_map_key("CFO"),
# the attribute map is the second element of the tuple
ctxh.cdt_ctx_list_index(1),
]
ops = [
# give the unicorn award exactly once
mh.map_put(
"scores", "awards", {"🦄": 1}, {
"map_write_flags": aerospike.MAP_WRITE_FLAGS_CREATE_ONLY
| aerospike.MAP_WRITE_FLAGS_NO_FAIL
}, ctx)
]
k, m, b = client.operate(key, ops)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment