Permalink
Browse files

updated riak extension to 1) not conflict with riak package, 2) save …

…each session as its own key (using the same _format_key logic as Redis)
  • Loading branch information...
1 parent d0006ca commit 210ab1fe5252f86cb7aa9061731d6b654129ea98 @andrewzeneski andrewzeneski committed Feb 26, 2013
Showing with 13 additions and 5 deletions.
  1. +12 −4 beaker_extensions/{riak.py → riak_.py}
  2. +1 −1 setup.py
@@ -23,16 +23,24 @@ def open_connection(self, host, port):
self.bucket = self.db_conn.bucket('beaker_cache')
def __contains__(self, key):
- return self.bucket.get(key).exists()
+ return self.bucket.get(self._format_key(key)).exists()
def set_value(self, key, value):
- self.bucket.new(key, value).store()
+ val = self.bucket.get(self._format_key(key))
+ if not val.exists():
+ self.bucket.new(self._format_key(key), value).store()
+ else:
+ val.set_data(value)
+ val.store()
def __getitem__(self, key):
- return self.bucket.get(key)
+ return self.bucket.get(self._format_key(key)).get_data()
def __delitem__(self, key):
- self.bucket.get(key).delete()
+ self.bucket.get(self._format_key(key)).delete()
+
+ def _format_key(self, key):
+ return 'beaker:%s:%s' % (self.namespace, key.replace(' ', '\302\267'))
def do_remove(self):
raise Exception("Unimplemented")
View
@@ -25,7 +25,7 @@
[beaker.backends]
redis = beaker_extensions.redis_:RedisManager
tyrant = beaker_extensions.tyrant_:TokyoTyrantManager
- riak = beaker_extensions.riak:RiakManager
+ riak = beaker_extensions.riak_:RiakManager
dynomite = beaker_extensions.dynomite_:DynomiteManager
ringo = beaker_extensions.ringo:RingoManager
cassandra = beaker_extensions.cassandra:CassandraManager

0 comments on commit 210ab1f

Please sign in to comment.