Skip to content

Instantly share code, notes, and snippets.

@rbotzer
Created November 2, 2019 04:52
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 rbotzer/de7d3bb86c0d385f2d86406493ca3c26 to your computer and use it in GitHub Desktop.
Save rbotzer/de7d3bb86c0d385f2d86406493ca3c26 to your computer and use it in GitHub Desktop.
# assuming it's given once a day, grant the 'top score' award to the
# current top score
ctx = [
ctxh.cdt_ctx_map_rank(-1),
# the attribute map is the second element of the tuple
ctxh.cdt_ctx_list_index(1),
]
ctx2 = ctx + [ctxh.cdt_ctx_map_key("awards")]
ops = [
# create the top score award if it doesn't exist
mh.map_put("scores", "awards", {"🏆": 0}, {
"map_write_flags": aerospike.MAP_WRITE_FLAGS_CREATE_ONLY
| aerospike.MAP_WRITE_FLAGS_NO_FAIL
}, ctx),
mh.map_increment("scores", "🏆", 1, ctx=ctx2),
]
client.operate(key, ops)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment