class Azu::Cache::MemoryStore

Overview

Memory-based cache store with LRU eviction

Defined in:

azu/cache.cr

Constant Summary

DEFAULT_MAX_SIZE = 1000
DEFAULT_TTL = Time::Span.new(hours: 1)

Constructors

Instance Method Summary

Instance methods inherited from class Azu::Cache::Store

clear : Bool clear, decrement(key : String, amount : Int32 = 1, ttl : Time::Span | Nil = nil) : Int32 | Nil decrement, delete(key : String) : Bool delete, exists?(key : String) : Bool exists?, fetch(key : String, ttl : Time::Span | Nil = nil, & : -> String) : String fetch, get(key : String) : String | Nil
get(key : String, ttl : Time::Span | Nil = nil, & : -> String) : String
get
, get_multi(keys : Array(String)) : Hash(String, String | Nil) get_multi, increment(key : String, amount : Int32 = 1, ttl : Time::Span | Nil = nil) : Int32 | Nil increment, set(key : String, value : String, ttl : Time::Span | Nil = nil) : Bool set, set_multi(values : Hash(String, String), ttl : Time::Span | Nil = nil) : Bool set_multi, size : Int32 size

Constructor Detail

def self.new(max_size : Int32 = DEFAULT_MAX_SIZE, default_ttl : Time::Span | Nil = DEFAULT_TTL, cleanup_interval : Time::Span = 5.minutes) #

[View source]

Instance Method Detail

def clear : Bool #

[View source]
def decrement(key : String, amount : Int32 = 1, ttl : Time::Span | Nil = nil) : Int32 | Nil #

Override decrement with atomic implementation


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

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

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

[View source]
def increment(key : String, amount : Int32 = 1, ttl : Time::Span | Nil = nil) : Int32 | Nil #

Override increment with atomic implementation


[View source]
def set(key : String, value : String, ttl : Time::Span | Nil = nil) : Bool #

[View source]
def size : Int32 #

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

Memory store specific methods


[View source]
def stop_cleanup_task #

Stop cleanup task (for testing or shutdown)


[View source]