Skip to content

Commit

Permalink
Updated riak backend to work with the latest client (2.0.1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marius Cobzarenco committed Sep 21, 2013
1 parent 5d42897 commit d4e3f4b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions beaker_extensions/riak_.py
Expand Up @@ -19,22 +19,22 @@ def __init__(self, namespace, url=None, data_dir=None, lock_dir=None, **params):
NoSqlManager.__init__(self, namespace, url=url, data_dir=data_dir, lock_dir=lock_dir, **params)

def open_connection(self, host, port):
self.db_conn = riak.RiakClient(host=host, port=int(port))
self.db_conn = riak.RiakClient(protocol='pbc', host=host, pb_port=int(port))
self.bucket = self.db_conn.bucket('beaker_cache')

def __contains__(self, key):
return self.bucket.get(self._format_key(key)).exists()
return self.bucket.get(self._format_key(key)).exists

def set_value(self, key, value):
val = self.bucket.get(self._format_key(key))
if not val.exists():
if not val.exists:
self.bucket.new(self._format_key(key), value).store()
else:
val.set_data(value)
val.data = value
val.store()

def __getitem__(self, key):
return self.bucket.get(self._format_key(key)).get_data()
return self.bucket.get(self._format_key(key)).data

def __delitem__(self, key):
self.bucket.get(self._format_key(key)).delete()
Expand Down

0 comments on commit d4e3f4b

Please sign in to comment.