class CQL::Cache::FragmentCache

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.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(cache : CacheInterface, strategy : InvalidationStrategy, config : CacheConfig = CacheConfig.new) #

[View source]

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


[View source]
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


[View source]
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


[View source]
def delete_fragment(fragment_name : String, params : Hash(String, DB::Any) = {} of String => DB::Any) : Bool #

Delete a specific fragment


[View source]
def fragment_cached?(fragment_name : String, params : Hash(String, DB::Any) = {} of String => DB::Any) : Bool #

Check if a fragment is cached


[View source]
def generate_fragment_key(fragment_name : String, params : Hash(String, DB::Any) = {} of String => DB::Any) : String #

Generate cache key with consistent hashing


[View source]
def generate_query_key(sql : String, params : Array(DB::Any) = [] of DB::Any) : String #

Generate cache key for SQL queries


[View source]
def get_fragment(fragment_name : String, params : Hash(String, DB::Any) = {} of String => DB::Any) : String | Nil #

Get a cached fragment


[View source]
def invalidate_tags(tags : Array(String)) : Int32 #

Invalidate fragments by tags


[View source]
def stats : Hash(String, String | Int32 | Int64 | Float64) #

Statistics about fragment cache usage


[View source]