Let the SessionManager use a cacheclass instead of plain dict.
This commit is contained in:
parent
b247ba3d63
commit
0de755f138
2 changed files with 5 additions and 3 deletions
|
@ -33,7 +33,7 @@ site.debug = True
|
||||||
|
|
||||||
P = etiquette.photodb.PhotoDB()
|
P = etiquette.photodb.PhotoDB()
|
||||||
|
|
||||||
session_manager = sessions.SessionManager()
|
session_manager = sessions.SessionManager(maxlen=10000)
|
||||||
|
|
||||||
|
|
||||||
def P_wrapper(function):
|
def P_wrapper(function):
|
||||||
|
|
|
@ -6,6 +6,8 @@ import werkzeug.wrappers
|
||||||
|
|
||||||
import etiquette
|
import etiquette
|
||||||
|
|
||||||
|
from voussoirkit import cacheclass
|
||||||
|
|
||||||
SESSION_MAX_AGE = 86400
|
SESSION_MAX_AGE = 86400
|
||||||
REQUEST_TYPES = (flask.Request, werkzeug.wrappers.Request, werkzeug.local.LocalProxy)
|
REQUEST_TYPES = (flask.Request, werkzeug.wrappers.Request, werkzeug.local.LocalProxy)
|
||||||
|
|
||||||
|
@ -30,8 +32,8 @@ def _normalize_token(token):
|
||||||
|
|
||||||
|
|
||||||
class SessionManager:
|
class SessionManager:
|
||||||
def __init__(self):
|
def __init__(self, maxlen=None):
|
||||||
self.sessions = {}
|
self.sessions = cacheclass.Cache(maxlen=maxlen)
|
||||||
|
|
||||||
def add(self, session):
|
def add(self, session):
|
||||||
self.sessions[session.token] = session
|
self.sessions[session.token] = session
|
||||||
|
|
Loading…
Reference in a new issue