Created
February 16, 2020 05:12
-
-
Save rbotzer/124a49350bb09174b71faadaf42ae671 to your computer and use it in GitHub Desktop.
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
# Update multiple segments of a user profile | |
segments = {} | |
ttl_dt = now + datetime.timedelta(days=30) | |
segment_ttl = int((ttl_dt - epoch).total_seconds() / 3600) | |
for i in range(8): | |
segment_id = random.randint(0, 81999) | |
segments[segment_id] = [segment_ttl, {}] | |
print("\nUpdating multiple segments for user u1") | |
pp.pprint(segments) | |
if options.interactive: | |
pause() | |
ops = [ | |
mh.map_put_items("u", segments), | |
mh.map_get_by_value( | |
"u", [segment_ttl, aerospike.CDTWildcard()], aerospike.MAP_RETURN_KEY_VALUE | |
), | |
] | |
_, _, b = client.operate(key, ops) | |
print("Show all segments with TTL {}:".format(segment_ttl)) | |
print(b["u"]) | |
print(spacer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment