core.py 777 B

1234567891011121314151617181920212223242526272829
  1. # SPDX-License-Identifier: AGPL-3.0-or-later
  2. # pylint: disable=missing-module-docstring
  3. from __future__ import annotations
  4. import pathlib
  5. from searx import logger
  6. from searx.cache import ExpireCacheCfg, ExpireCacheSQLite
  7. log = logger.getChild("data")
  8. data_dir = pathlib.Path(__file__).parent
  9. _DATA_CACHE: ExpireCacheSQLite = None # type: ignore
  10. def get_cache():
  11. global _DATA_CACHE # pylint: disable=global-statement
  12. if _DATA_CACHE is None:
  13. _DATA_CACHE = ExpireCacheSQLite.build_cache(
  14. ExpireCacheCfg(
  15. name="DATA_CACHE",
  16. # MAX_VALUE_LEN=1024 * 200, # max. 200kB length for a *serialized* value.
  17. # MAXHOLD_TIME=60 * 60 * 24 * 7 * 4, # 4 weeks
  18. )
  19. )
  20. return _DATA_CACHE