Class: HTM::QueryCache¶
Inherits: Object
Thread-safe query result cache with TTL and statistics
Provides LRU caching for expensive query results with: * Configurable size and TTL * Thread-safe statistics tracking * Fast cache key generation (using Ruby's built-in hash) * Selective cache invalidation by method type
@example
@example
@example
@example
Attributes¶
enabled[RW]¶
Returns the value of attribute enabled.
Instance Methods¶
clear!()¶
Clear all cached entries
@return [void]
enabled?()¶
Check if cache is enabled
@return [Boolean]
fetch(method, *args, &block)¶
Fetch a value from cache or execute block
@param [Symbol] Method name for cache key
@param [Array] Arguments for cache key
@return [Object] Cached or computed value
@yield [] Block that computes the value if not cached
initialize(size:1000, ttl:300)¶
Initialize a new query cache
@param [Integer] Maximum number of entries (default: 1000, use 0 to disable)
@param [Integer] Time-to-live in seconds (default: 300)
@return [QueryCache] a new instance of QueryCache
invalidate!()¶
Invalidate cache (alias for clear!)
@return [void]
invalidate_methods!(*methods)¶
Invalidate cache entries for specific methods only
More efficient than full invalidation when only certain types of cached data need to be refreshed.
@param [Array
@return [Integer] Number of entries invalidated
stats()¶
Get cache statistics
@return [Hash, nil] Statistics hash or nil if disabled