configurable in-memory cache sizes
This commit is contained in:
parent
62ce1ab1e0
commit
a8261d0b3d
3 changed files with 8 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
import json
|
||||
from functools import wraps
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.db.models import Prefetch
|
||||
from django.utils.cache import get_conditional_response
|
||||
|
@ -15,7 +16,7 @@ from c3nav.mapdata.models.locations import SpecificLocation
|
|||
from c3nav.mapdata.utils.cache.local import LocalCacheProxy
|
||||
from c3nav.mapdata.utils.cache.stats import increment_cache_key
|
||||
|
||||
request_cache = LocalCacheProxy(maxsize=64)
|
||||
request_cache = LocalCacheProxy(maxsize=settings.CACHE_SIZE_API)
|
||||
|
||||
|
||||
def api_etag(permissions=True, etag_func=AccessPermission.etag_func, base_mapdata=False):
|
||||
|
|
|
@ -8,6 +8,7 @@ from itertools import chain
|
|||
from typing import Any, List, Mapping, Optional, Union
|
||||
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
from django.db.models import Prefetch, Q
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
@ -24,7 +25,7 @@ from c3nav.mapdata.utils.cache.local import LocalCacheProxy
|
|||
from c3nav.mapdata.utils.geometry import unwrap_geom
|
||||
from c3nav.mapdata.utils.models import get_submodels
|
||||
|
||||
proxied_cache = LocalCacheProxy(maxsize=128)
|
||||
proxied_cache = LocalCacheProxy(maxsize=settings.CACHE_SIZE_LOCATIONS)
|
||||
|
||||
|
||||
def locations_for_request(request) -> Mapping[int, LocationSlug]:
|
||||
|
|
|
@ -155,6 +155,10 @@ ENABLE_MESH = config.getboolean('c3nav', 'enable_mesh', fallback=True, env='ENAB
|
|||
SERVE_ANYTHING = config.getboolean('c3nav', 'serve_anything', fallback=True, env='SERVE_ANYTHING')
|
||||
SERVE_API = config.getboolean('c3nav', 'serve_api', fallback=SERVE_ANYTHING, env='SERVE_API')
|
||||
|
||||
# how many location lookups to cache in each worker's in-memory LRU cache proxy
|
||||
CACHE_SIZE_LOCATIONS = config.getint('c3nav', 'cache_size_locations', fallback=128)
|
||||
CACHE_SIZE_API = config.getint('c3nav', 'cache_size_api', fallback=64)
|
||||
|
||||
RENDER_SCALE = config.getfloat('c3nav', 'render_scale', fallback=20.0)
|
||||
IMAGE_RENDERER = config.get('c3nav', 'image_renderer', fallback='svg')
|
||||
SVG_RENDERER = config.get('c3nav', 'svg_renderer', fallback='rsvg-convert')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue