abstract class Azu::Cache::Store

Overview

Base cache store interface

Direct Known Subclasses

Defined in:

azu/cache.cr

Instance Method Summary

Instance Method Detail

abstract def clear : Bool #

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

Decrement counter

WARNING Base implementation is NOT thread-safe for concurrent access MemoryStore and RedisStore override with atomic implementations


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

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

[View source]
def fetch(key : String, ttl : Time::Span | Nil = nil, & : -> String) : String #

Rails-like fetch method with block support (preferred method)


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

[View source]
def get(key : String, ttl : Time::Span | Nil = nil, & : -> String) : String #

Overloaded get method with block and TTL support @deprecated Use #fetch instead for Rails-like cache-aside pattern. The #get method with a block is deprecated and will be removed in a future version. Replace: cache.get("key", ttl: 1.hour) { compute_value } With: cache.fetch("key", ttl: 1.hour) { compute_value }

DEPRECATED Use #fetch instead for cache-aside pattern with block


[View source]
def get_multi(keys : Array(String)) : Hash(String, String | Nil) #

Multi-get support


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

Increment counter (for stores that support it)

WARNING Base implementation is NOT thread-safe for concurrent access MemoryStore and RedisStore override with atomic implementations


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

[View source]
def set_multi(values : Hash(String, String), ttl : Time::Span | Nil = nil) : Bool #

Multi-set support


[View source]
abstract def size : Int32 #

[View source]