Add pylibmc and pymemcache to requirements and make timeout not lazy (#116)

This commit is contained in:
Michael Manfre 2022-12-05 16:48:02 -05:00 committed by GitHub
parent 22e25ac454
commit 238268eb31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -16,8 +16,7 @@ def cache_page(
timeout can either be the number of seconds or the name of a SystemOptions timeout can either be the number of seconds or the name of a SystemOptions
value. value.
""" """
if isinstance(timeout, str): _timeout = timeout
timeout = Config.lazy_system_value(timeout)
def decorator(function): def decorator(function):
@wraps(function) @wraps(function)
@ -26,10 +25,11 @@ def cache_page(
if per_identity: if per_identity:
identity_id = request.identity.pk if request.identity else "0" identity_id = request.identity.pk if request.identity else "0"
prefix = f"{key_prefix or ''}:ident{identity_id}" prefix = f"{key_prefix or ''}:ident{identity_id}"
_timeout = timeout if isinstance(_timeout, str):
if callable(_timeout): timeout = getattr(Config.system, _timeout)
_timeout = _timeout() else:
return dj_cache_page(timeout=_timeout, key_prefix=prefix)(function)( timeout = _timeout
return dj_cache_page(timeout=timeout, key_prefix=prefix)(function)(
request, *args, **kwargs request, *args, **kwargs
) )

View File

@ -13,6 +13,8 @@ pillow~=9.3.0
psycopg2~=2.9.5 psycopg2~=2.9.5
pydantic~=1.10.2 pydantic~=1.10.2
pyld~=2.0.3 pyld~=2.0.3
pylibmc~=1.6.3
pymemcache~=4.0.0
python-dotenv~=0.21.0 python-dotenv~=0.21.0
sentry-sdk~=1.11.0 sentry-sdk~=1.11.0
sphinx~=5.3.0 sphinx~=5.3.0