cache_config.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # ==================== cache_config.py ====================
  2. """
  3. Centralized cache configuration for the application.
  4. Set ENABLE_CACHING to True to enable all caches, False to disable.
  5. """
  6. # ⚡ MASTER CACHE CONTROL - Change this single variable to enable/disable ALL caching
  7. ENABLE_CACHING = False # Default: OFF
  8. # Individual cache controls (controlled by ENABLE_CACHING)
  9. ENABLE_ATTRIBUTE_EXTRACTION_CACHE = ENABLE_CACHING
  10. ENABLE_EMBEDDING_CACHE = ENABLE_CACHING
  11. ENABLE_CLIP_MODEL_CACHE = ENABLE_CACHING
  12. # Cache size limits (only used when caching is enabled)
  13. ATTRIBUTE_CACHE_MAX_SIZE = 1000
  14. EMBEDDING_CACHE_MAX_SIZE = 500
  15. def is_caching_enabled() -> bool:
  16. """
  17. Check if caching is enabled globally.
  18. Returns: bool indicating if caching is enabled
  19. """
  20. return ENABLE_CACHING
  21. def get_cache_config() -> dict:
  22. """
  23. Get current cache configuration.
  24. Returns: dict with cache settings
  25. """
  26. return {
  27. "master_cache_enabled": ENABLE_CACHING,
  28. "attribute_extraction_cache": ENABLE_ATTRIBUTE_EXTRACTION_CACHE,
  29. "embedding_cache": ENABLE_EMBEDDING_CACHE,
  30. "clip_model_cache": ENABLE_CLIP_MODEL_CACHE,
  31. "attribute_cache_max_size": ATTRIBUTE_CACHE_MAX_SIZE,
  32. "embedding_cache_max_size": EMBEDDING_CACHE_MAX_SIZE
  33. }