Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a new keyword argument expiretime to nosql.py

Allow NoSqlManager to accept a new keyword argument expire, which is
accepted as an optional argument by the method set_value in redis.py to
specify the expire time in seconds for the session object
  • Loading branch information...
commit d14f43e9b1b933b79dcdadbda54559da0066c098 1 parent d0006ca
@XiaonuoGantan XiaonuoGantan authored
Showing with 6 additions and 2 deletions.
  1. +2 −0  .gitignore
  2. +4 −2 beaker_extensions/nosql.py
View
2  .gitignore
@@ -1,3 +1,5 @@
*.py?
*.egg-info
*.swp
+build/
+dist/
View
6 beaker_extensions/nosql.py
@@ -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)
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)]
Please sign in to comment.
Something went wrong with that request. Please try again.