Selecto.Performance.QueryCache (Selecto v0.4.3)
High-performance query result caching for Selecto.
Provides intelligent caching of query results with:
- Automatic cache key generation from SQL and parameters
- TTL-based expiration
- Size-based eviction (LRU)
- Cache invalidation strategies
- Cache statistics and monitoring
- ETS-backed low-latency reads
Link to this section Summary
Functions
Execute a query with caching.
Returns a specification to start this module under a supervisor.
Clear entire cache.
Generate a cache key from Selecto query.
Generate a cache key from SQL and parameters.
Get a cached query result.
Invalidate cache entries by key or pattern.
Invalidate cache entries by tags.
Store a query result in cache.
Start the query cache process.
Get cache statistics.
Warm up cache with frequently used queries.
Link to this section Functions
cached_execute(selecto, execute_fn, options \\ [])
Execute a query with caching.
This is a convenience function that checks cache, executes if needed, and caches the result.
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor.
clear()
Clear entire cache.
generate_key(selecto)
Generate a cache key from Selecto query.
generate_key_from_sql(sql, params)
Generate a cache key from SQL and parameters.
get(cache_key)
Get a cached query result.
Returns {:ok, result} if found, :miss if not in cache.
invalidate(key_or_pattern)
Invalidate cache entries by key or pattern.
invalidate_by_tags(tags)
Invalidate cache entries by tags.
put(cache_key, result, options \\ [])
Store a query result in cache.
options
Options
:ttl- Override default TTL for this entry:tags- Tags for cache invalidation:compress- Force compression for this entry
start_link(opts \\ [])
Start the query cache process.
options
Options
:max_size- Maximum number of cached queries (default: 1000):default_ttl- Default TTL in milliseconds (default: 5 minutes):eviction_policy- :lru, :lfu, or :ttl (default: :lru):cache_backend- :ets (default: :ets):track_stats- Enable cache statistics (default: true):compression- Enable result compression (default: false)
stats()
Get cache statistics.
warmup(queries)
Warm up cache with frequently used queries.