From af364766082735056c477d51f8a7eb1e1ab5c5df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Tue, 24 Sep 2024 16:46:55 +0200 Subject: [PATCH] Disable the cache view by default --- doc/developer/debugging.rst | 12 ++++++++++++ doc/integrator/c2cwsgiutils.rst | 2 +- geoportal/c2cgeoportal_geoportal/views/memory.py | 9 +++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/doc/developer/debugging.rst b/doc/developer/debugging.rst index 7676a32fb5..899cb70aae 100644 --- a/doc/developer/debugging.rst +++ b/doc/developer/debugging.rst @@ -76,6 +76,18 @@ To be automatically logged in with a user present in the database you should set Then you will directly be logged in to the user. +C2C WSGI Utils tools +-------------------- + +:ref:`integrator_c2cwsgiutils` offers some debugging tools on the URL ``/c2c``. + +Cache +----- + +There a view that expose the cache status of the application, to be able to access to this view you should +set the environment variable ``GEOMAPFISH_DEBUG_MEMORY_CACHE`` to ``true``. + +Then you can access the cache status through the :ref:`integrator_c2cwsgiutils` ``/c2c`` URL. Mapserver --------- diff --git a/doc/integrator/c2cwsgiutils.rst b/doc/integrator/c2cwsgiutils.rst index 9529a79724..2939ef85b7 100644 --- a/doc/integrator/c2cwsgiutils.rst +++ b/doc/integrator/c2cwsgiutils.rst @@ -5,7 +5,7 @@ C2C WSGI Utils ``c2cwsgiutils`` is a framework assisting in development, integration and administration of WSGI applications. ``c2cgeoportal`` uses ``c2cwsgiutils``. -See its `documentation `__. +See its `documentation `_. The entry point URL is ``/c2c``, where you will have a dashboard with the ``c2cwsgiutils`` and ``c2cgeoportal`` services. diff --git a/geoportal/c2cgeoportal_geoportal/views/memory.py b/geoportal/c2cgeoportal_geoportal/views/memory.py index d8d6c6ae72..529ec7c7a2 100644 --- a/geoportal/c2cgeoportal_geoportal/views/memory.py +++ b/geoportal/c2cgeoportal_geoportal/views/memory.py @@ -27,6 +27,7 @@ import logging +import os import time from typing import Any, cast @@ -83,7 +84,7 @@ def _process_dict(dict_: dict[str, Any], dogpile_cache: bool = False) -> dict[st @broadcast.decorator(expect_answers=True, timeout=110) def _memory() -> dict[str, Any]: - return { - "raster_data": _process_dict(raster.Raster.data), - "memory_cache": _process_dict(MEMORY_CACHE_DICT, True), - } + result = {"raster_data": _process_dict(raster.Raster.data)} + if os.environ.get("GEOMAPFISH_DEBUG_MEMORY_CACHE", "false").lower() in ("true", "1", "yes", "on"): + result["memory_cache"] = _process_dict(MEMORY_CACHE_DICT, True) + return result