0

What i would like to do is set a timeout for individual keys in riak I know that you can set a timeout on using bitcask but if im not mistaken that is only to the buckets i have a method where i could implement the timeout functionality manually but that would involve altering the metadata for that key

import riak

client = riak.RiakClient() 
bucket = client.bucket('somebucket')
key = bucket.get('somekey')
old_meta = key.get_metadata()
old_meta['new_key'] = 'new_value'
key.set_metadata(old_meta).store()

either the metadata does not update or it does not show immediately or am i missing something here .. ?

Aatish Molasi
  • 2,138
  • 3
  • 20
  • 43

1 Answers1

1

The dictionary contains one entry for each type of metadata (keys can be found here). User metadata can therefore be set the following way:

client = riak.RiakClient(port=10018)
bucket = client.bucket('somebucket')
key = bucket.get('somekey')
old_meta = key.get_metadata()
old_meta['usermeta'] = {'new_key': 'new_value'}
key.set_metadata(old_meta).store()
Christian Dahlqvist
  • 1,665
  • 12
  • 9