Skip to content

Commit

Permalink
fix: use seconds for default value in cache_control_ttl
Browse files Browse the repository at this point in the history
  • Loading branch information
Krukov committed May 10, 2024
1 parent 6ddbaae commit 2d7488a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
3 changes: 2 additions & 1 deletion cashews/contrib/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from starlette.requests import Request
from starlette.responses import Response
from starlette.types import ASGIApp
from ttl import ttl_to_seconds

from cashews import Cache, Command, cache, invalidate_further
from cashews._typing import TTL
Expand Down Expand Up @@ -41,7 +42,7 @@

def cache_control_ttl(default: TTL):
def _ttl(*args, **kwargs):
return _cache_max_age.get(default)
return _cache_max_age.get(ttl_to_seconds(default))

return _ttl

Expand Down
42 changes: 19 additions & 23 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
[tox]
envlist =
{py38,py39,py310,py311,py312}
{py38,py39,py310,py311,py312}-redis
{py38,py39,py310,py311,py312}-redis4
{py38,py39,py310,py311,py312}-diskcache
{py38,py39,py310,py311,py312}-integration
{py38,py39,py310,py311,py312}-{redis,redis4,diskcache,integration}
coverage
skip_missing_interpreters = true

Expand All @@ -15,22 +11,22 @@ setenv =
PYTHONPATH = {toxinidir}/tests
COVERAGE_FILE = {toxworkdir}/.coverage.{envname}
MARKER = not redis and not integration and not diskcache
{py,py38,py39,py310,py311,py312}-redis: MARKER = redis and not diskcache
{py,py38,py39,py310,py311,py312}-redis4: MARKER = redis and not diskcache
{py,py38,py39,py310,py311,py312}-diskcache: MARKER = diskcache and not redis
{py,py38,py39,py310,py311,py312}-integration: MARKER = integration
{py}-redis: MARKER = redis and not diskcache
{py}-redis4: MARKER = redis and not diskcache
{py}-diskcache: MARKER = diskcache and not redis
{py}-integration: MARKER = integration
deps =
.[tests]
{py,py38,py39,py310,py311,py312}-redis4: redis==4.6.0
{py,py38,py39,py310,py311,py312}-integration: aiohttp
{py,py38,py39,py310,py311,py312}-integration: fastapi
{py,py38,py39,py310,py311,py312}-integration: httpx
{py,py38,py39,py310,py311,py312}-integration: SQLAlchemy
{py,py38,py39,py310,py311,py312}-integration: prometheus-client
{py}-redis4: redis==4.6.0
{py}-integration: aiohttp
{py}-integration: fastapi
{py}-integration: httpx
{py}-integration: SQLAlchemy
{py}-integration: prometheus-client
extras =
{py,py38,py39,py310,py311,py312}-redis: redis,speedup
{py,py38,py39,py310,py311,py312}-diskcache: diskcache
{py,py37,py38,py39,py310,py311,py312}-integration: redis,speedup,diskcache,dill
{py}-redis: redis,speedup
{py}-diskcache: diskcache
{py}-integration: redis,speedup,diskcache,dill
commands =
pytest --cov --cov-fail-under=0 --reruns 5 --reruns-delay 1 --exitfirst \
-m "{env:MARKER}" \
Expand All @@ -48,8 +44,8 @@ commands =
coverage report
coverage xml -o {toxworkdir}/coverage.xml
depends =
{py38,py39,py310,py311,py312}
{py38,py39,py310,py311,py312}-redis
{py38,py39,py310,py311,py312}-redis4
{py38,py39,py310,py311,py312}-diskcache
{py38,py39,py310,py311,py312}-integration
{py}
{py}-redis
{py}-redis4
{py}-diskcache
{py}-integration

0 comments on commit 2d7488a

Please sign in to comment.