wjlroe

spam_riak.py

Jul 5th, 2011
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. import riak
  2.  
  3. if __name__ == '__main__':
  4.     client = riak.RiakClient()
  5.  
  6.     bucket1 = client.bucket('test_bucket_spam')
  7.     bucket2 = client.bucket('test_bucket')
  8.  
  9.     single_obj = bucket2.get("hello")
  10.     if not single_obj.exists():
  11.         single_obj = bucket2.new("hello", data={})
  12.  
  13.     for i in xrange(1,160):
  14.         new_spam = bucket1.new("spam%s" % str(i), data={})
  15.         new_spam.add_link(single_obj, 'single')
  16.         new_spam.store()
  17.         single_obj.add_link(new_spam, 'spam')
  18.     print 'Obj has %s links' % len(single_obj.get_links())
  19.     single_obj.store()
  20.  
  21.     # with or without this, it fails
  22.     single_obj.reload()
  23.  
  24.     for i in xrange(161,250):
  25.         new_spam = bucket1.new("spam%s" % str(i), data={})
  26.         new_spam.add_link(single_obj, 'single')
  27.         new_spam.store()
  28.         single_obj.add_link(new_spam, 'spam')
  29.     print 'Obj has %s links' % len(single_obj.get_links())
  30.     single_obj.store()
Advertisement
Add Comment
Please, Sign In to add comment