Created
February 16, 2020 04:37
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Upsert a single segment in the user profile | |
key = (namespace, set, "u1") | |
segment_id = random.randint(0, 81999) | |
ttl_dt = now + datetime.timedelta(days=30) | |
segment_ttl = int((ttl_dt - epoch).total_seconds() / 3600) | |
ops = [ | |
mh.map_get_by_key("u", segment_id, aerospike.MAP_RETURN_KEY_VALUE), | |
mh.map_put("u", segment_id, [segment_ttl, {}]), | |
mh.map_get_by_key("u", segment_id, aerospike.MAP_RETURN_KEY_VALUE), | |
] | |
print("\nUpsert segment {} => [{}] to user u1".format(segment_id, segment_ttl)) | |
if options.interactive: | |
pause() | |
_, _, b = client.operate_ordered(key, ops) | |
segment_check, segment_count, new_segment = b | |
print("Segment value before: {}".format(segment_check[1])) | |
print("Number of segments after upsert: {}".format(segment_count[1])) | |
print("Segment value after: {}".format(new_segment[1])) | |
print(spacer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment