Let the SessionManager use a cacheclass instead of plain dict.

This commit is contained in:
voussoir 2018-03-18 21:23:48 -07:00
parent b247ba3d63
commit 0de755f138
2 changed files with 5 additions and 3 deletions

View file

@ -33,7 +33,7 @@ site.debug = True
P = etiquette.photodb.PhotoDB()
session_manager = sessions.SessionManager()
session_manager = sessions.SessionManager(maxlen=10000)
def P_wrapper(function):

View file

@ -6,6 +6,8 @@ import werkzeug.wrappers
import etiquette
from voussoirkit import cacheclass
SESSION_MAX_AGE = 86400
REQUEST_TYPES = (flask.Request, werkzeug.wrappers.Request, werkzeug.local.LocalProxy)
@ -30,8 +32,8 @@ def _normalize_token(token):
class SessionManager:
def __init__(self):
self.sessions = {}
def __init__(self, maxlen=None):
self.sessions = cacheclass.Cache(maxlen=maxlen)
def add(self, session):
self.sessions[session.token] = session