Skip to main content
Glama
cache.py1.15 kB
""" Cache Configuration Module Defines and configures in-memory caches for the application. This module uses 'cachetools' to provide Time-To-Live (TTL) caching for frequently accessed, semi-static data. """ from cachetools import TTLCache, cached from functools import partial # --- Cache Configurations --- # Cache for Periscope schemas: # - maxsize=100: Store up to 100 unique stream schemas. # - ttl=3600: Cache each schema for 1 hour (3600 seconds). schema_cache = TTLCache(maxsize=100, ttl=3600) # Cache for Periscope search results: # - maxsize=1000: Store up to 1000 unique search query results. # - ttl=300: Cache each search result for 5 minutes (300 seconds). search_cache = TTLCache(maxsize=1000, ttl=300) # --- Caching Decorators --- # These decorators can be applied to functions to enable caching. # This approach defines a wrapper to correctly apply the 'cached' decorator. def cache_schema(func): """Decorator for caching schema-related functions.""" return cached(cache=schema_cache)(func) def cache_search(func): """Decorator for caching search-related functions.""" return cached(cache=search_cache)(func)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gaharivatsa/KIBANA_SERVER'

If you have feedback or need assistance with the MCP directory API, please join our Discord server