aarondb/cache
Types
pub type CacheConfig(k, v) {
CacheConfig(
max_size: Int,
invalidator: fn(fact.Datom, k) -> Bool,
)
}
Constructors
-
CacheConfig( max_size: Int, invalidator: fn(fact.Datom, k) -> Bool, )
pub type Message(k, v) {
Get(k, process.Subject(option.Option(v)))
Set(k, v)
Invalidate(k)
Clear
HandleWal(List(fact.Datom))
}
Constructors
-
Get(k, process.Subject(option.Option(v))) -
Set(k, v) -
Invalidate(k) -
Clear -
HandleWal(List(fact.Datom))
Values
pub fn get(
cache: process.Subject(Message(k, v)),
key: k,
) -> option.Option(v)
Convenience function to wrap a cache in a simple get/set interface.
pub fn invalidate(
cache: process.Subject(Message(k, v)),
key: k,
) -> Nil
pub fn set(
cache: process.Subject(Message(k, v)),
key: k,
value: v,
) -> Nil
pub fn start(
config: CacheConfig(k, v),
) -> Result(process.Subject(Message(k, v)), actor.StartError)
Start a new LRU cache actor with the given configuration.
pub fn start_reactive(
db: process.Subject(transactor.Message),
config: CacheConfig(k, v),
) -> Result(process.Subject(Message(k, v)), actor.StartError)
Start a reactive cache that automatically invalidates based on database changes.