Permalink
Browse files

Merge pull request #15 from XiaonuoGantan/master

Allow NoSQL backends to accept an expire argument
  • Loading branch information...
2 parents f658f64 + d14f43e commit b45b10da0986120259abd0ad6cf3150c87377bd9 @didip committed Nov 20, 2013
Showing with 6 additions and 2 deletions.
  1. +2 −0 .gitignore
  2. +4 −2 beaker_extensions/nosql.py
View
@@ -2,3 +2,5 @@ build
*.py?
*.egg-info
*.swp
+build/
+dist/
@@ -13,7 +13,7 @@
log = logging.getLogger(__name__)
class NoSqlManager(NamespaceManager):
- def __init__(self, namespace, url=None, data_dir=None, lock_dir=None, **params):
+ def __init__(self, namespace, url=None, data_dir=None, lock_dir=None, expire=None, **params):
NamespaceManager.__init__(self, namespace)
if not url:
@@ -26,6 +26,8 @@ def __init__(self, namespace, url=None, data_dir=None, lock_dir=None, **params):
if hasattr(self, 'lock_dir'):
verify_directory(self.lock_dir)
+ self._expiretime = int(expire) if expire else None
+
conn_params = {}
parts = url.split('?', 1)
url = parts[0]
@@ -60,7 +62,7 @@ def set_value(self, key, value):
self.db_conn[self._format_key(key)] = pickle.dumps(value, 2)
def __setitem__(self, key, value):
- self.set_value(key, value)
+ self.set_value(key, value, self._expiretime)
def __delitem__(self, key):
del self.db_conn[self._format_key(key)]

0 comments on commit b45b10d

Please sign in to comment.