class Session::LocalCache(T)

Overview

Local cache with TTL and LRU eviction Generic parameter T can be any type - when used for sessions, instantiate as LocalCache(T) where T is your session class that inherits from Session::Base

Defined in:

cluster.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(ttl : Time::Span = 30.seconds, max_size : Int32 = 10000) #

[View source]

Instance Method Detail

def clear : Nil #

Clear all entries from the cache


[View source]
def delete(key : String) : Bool #

Remove a key from the cache


[View source]
def get(key : String) : T | Nil #

Get a value from the cache, returning nil if expired or missing


[View source]
def reset_stats : Nil #

Reset statistics counters


[View source]
def set(key : String, value : T) : T #

Store a value in the cache with automatic TTL


[View source]
def size : Int32 #

Count of valid (non-expired) entries


[View source]
def stats : CacheStats #

Get cache statistics


[View source]