increment_cache_key() helper
This commit is contained in:
parent
b4f48473d0
commit
55384274a7
2 changed files with 11 additions and 5 deletions
|
@ -26,6 +26,7 @@ from c3nav.mapdata.models.geometry.space import (POI, Area, Column, CrossDescrip
|
|||
from c3nav.mapdata.models.level import Level
|
||||
from c3nav.mapdata.models.locations import (Location, LocationGroupCategory, LocationRedirect, LocationSlug,
|
||||
SpecificLocation)
|
||||
from c3nav.mapdata.utils.cache import increment_cache_key
|
||||
from c3nav.mapdata.utils.locations import (get_location_by_id_for_request, get_location_by_slug_for_request,
|
||||
searchable_locations_for_request, visible_locations_for_request)
|
||||
from c3nav.mapdata.utils.models import get_submodels
|
||||
|
@ -449,11 +450,7 @@ class UpdatesViewSet(GenericViewSet):
|
|||
except ValueError:
|
||||
pass
|
||||
|
||||
counter_key = 'api_updates_fetch_requests%s' % ('_cross_origin' if cross_origin is not None else '')
|
||||
try:
|
||||
cache.incr(counter_key)
|
||||
except ValueError:
|
||||
cache.set(counter_key, 0, None)
|
||||
increment_cache_key('api_updates_fetch_requests%s' % ('_cross_origin' if cross_origin is not None else ''))
|
||||
|
||||
from c3nav.site.models import SiteUpdate
|
||||
|
||||
|
|
9
src/c3nav/mapdata/utils/cache/__init__.py
vendored
9
src/c3nav/mapdata/utils/cache/__init__.py
vendored
|
@ -1,4 +1,13 @@
|
|||
from django.core.cache import cache
|
||||
|
||||
from c3nav.mapdata.utils.cache.indexed import GeometryIndexed # noqa
|
||||
from c3nav.mapdata.utils.cache.maphistory import MapHistory # noqa
|
||||
from c3nav.mapdata.utils.cache.accessrestrictions import AccessRestrictionAffected # noqa
|
||||
from c3nav.mapdata.utils.cache.package import CachePackage # noqa
|
||||
|
||||
|
||||
def increment_cache_key(cache_key):
|
||||
try:
|
||||
cache.incr(cache_key)
|
||||
except ValueError:
|
||||
cache.set(cache_key, 0, None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue