gacache

Types

Actions are passed to the Cache to interact with it’s Store

pub type Action(value) {
  Set(key: Key, value: value)
  Get(ret: process.Subject(Result(value, Error)), key: Key)
  Clear(key: Key)
  Keys(ret: process.Subject(List(Key)))
  Reset
  Raw(ret: process.Subject(Store(value)))
  Merge(store: Store(value))
  Stop
}

Constructors

  • Set(key: Key, value: value)
  • Get(ret: process.Subject(Result(value, Error)), key: Key)
  • Clear(key: Key)
  • Keys(ret: process.Subject(List(Key)))
  • Reset
  • Raw(ret: process.Subject(Store(value)))
  • Merge(store: Store(value))
  • Stop
pub type Error {
  NotCached
  Timeout
}

Constructors

  • NotCached

    Provided when the Get Action is sent with a Key that has no corresponding Value

  • Timeout

    Provided when either a Get or Raw Action cannot be completed in 10 seconds

Functions

pub fn clear(cache: Subject(Action(a)), key: String) -> Nil

Removes the Value associated with the provided Key from the Store

pub fn get(
  cache: Subject(Action(a)),
  key: String,
) -> Result(a, Error)
pub fn keys(cache: Subject(Action(a))) -> List(String)

Returns all keys known by the Store

pub fn merge(
  cache: Subject(Action(a)),
  new_store: Dict(String, a),
) -> Nil

Merges the Store with the provided Store using dict:merge/2

pub fn raw(
  cache: Subject(Action(a)),
) -> Result(Dict(String, a), Error)

Returns the Store, avoid if possible

pub fn reset(cache: Subject(Action(a))) -> Nil

Clears the whole Store

pub fn set(
  cache: Subject(Action(a)),
  key: String,
  value: a,
) -> Nil

Updates the Store with key=value

pub fn start() -> Result(Subject(Action(a)), StartError)

Start the cache

pub fn stop(cache: Subject(Action(a))) -> Nil

Stops the cache

Search Document