class
CQL::Cache::FragmentCache
- CQL::Cache::FragmentCache
- Reference
- Object
Overview
Fragment caching for arbitrary parts of queries or result sets Provides flexible caching with custom key generation and tag support
Defined in:
cache/fragment_cache.crConstructors
Instance Method Summary
-
#cache_fragment(fragment_name : String, params : Hash(String, DB::Any) = {} of String => DB::Any, tags : Array(String) = [] of String, ttl : Time::Span | Nil = nil, &block : -> String) : String | Nil
Cache a fragment with automatic key generation
-
#cache_query(sql : String, query_params : Array(DB::Any) = [] of DB::Any, cache_tags : Array(String) = [] of String, ttl : Time::Span = @config.default_ttl, &)
Query fragment caching for database results
-
#cache_with_key(cache_key : String, tags : Array(String) = [] of String, ttl : Time::Span = @config.default_ttl, &block : -> String) : String | Nil
Cache with explicit key
-
#delete_fragment(fragment_name : String, params : Hash(String, DB::Any) = {} of String => DB::Any) : Bool
Delete a specific fragment
-
#fragment_cached?(fragment_name : String, params : Hash(String, DB::Any) = {} of String => DB::Any) : Bool
Check if a fragment is cached
-
#generate_fragment_key(fragment_name : String, params : Hash(String, DB::Any) = {} of String => DB::Any) : String
Generate cache key with consistent hashing
-
#generate_query_key(sql : String, params : Array(DB::Any) = [] of DB::Any) : String
Generate cache key for SQL queries
-
#get_fragment(fragment_name : String, params : Hash(String, DB::Any) = {} of String => DB::Any) : String | Nil
Get a cached fragment
-
#invalidate_tags(tags : Array(String)) : Int32
Invalidate fragments by tags
-
#stats : Hash(String, String | Int32 | Int64 | Float64)
Statistics about fragment cache usage
Constructor Detail
def self.new(cache : CacheInterface, strategy : InvalidationStrategy, config : CacheConfig = CacheConfig.new)
#
Instance Method Detail
def cache_fragment(fragment_name : String, params : Hash(String, DB::Any) = {} of String => DB::Any, tags : Array(String) = [] of String, ttl : Time::Span | Nil = nil, &block : -> String) : String | Nil
#
Cache a fragment with automatic key generation
def cache_query(sql : String, query_params : Array(DB::Any) = [] of DB::Any, cache_tags : Array(String) = [] of String, ttl : Time::Span = @config.default_ttl, &)
#
Query fragment caching for database results
def cache_with_key(cache_key : String, tags : Array(String) = [] of String, ttl : Time::Span = @config.default_ttl, &block : -> String) : String | Nil
#
Cache with explicit key
def delete_fragment(fragment_name : String, params : Hash(String, DB::Any) = {} of String => DB::Any) : Bool
#
Delete a specific fragment
def fragment_cached?(fragment_name : String, params : Hash(String, DB::Any) = {} of String => DB::Any) : Bool
#
Check if a fragment is cached
def generate_fragment_key(fragment_name : String, params : Hash(String, DB::Any) = {} of String => DB::Any) : String
#
Generate cache key with consistent hashing
Generate cache key for SQL queries
def get_fragment(fragment_name : String, params : Hash(String, DB::Any) = {} of String => DB::Any) : String | Nil
#
Get a cached fragment