nebulex v1.0.0-rc.2 Nebulex.Adapter behaviour View Source

This module specifies the adapter API that a Cache adapter is required to implement.

Link to this section Summary

Callbacks

The callback invoked in case the adapter needs to inject code

Returns the children specs that starts the adapter process

Deletes a single object from Cache

Flushes the cache

Retrieves a single object from Cache

Gets the value from key and updates it, all in one pass

Returns whether the given key exists in Cache

Returns all cached keys

Returns and removes a single object from Cache if key exists, otherwise returns nil

Invokes reducer for each entry in the cache, passing the key, the return and the accumulator acc as arguments. reducer’s return value is stored in acc

Stores a single object in the Cache

Returns the cache size (total number of cached entries)

Returns a map with all cache entries

Updates the cached key with the given function

Updates (increment or decrement) the counter mapped to the given key

Link to this section Types

Link to this section Callbacks

Link to this macro callback __before_compile__(env) View Source
__before_compile__({line :: Macro.Env.line(), env :: Macro.Env.t()}, env :: Macro.Env.t()) :: Macro.t()

The callback invoked in case the adapter needs to inject code.

Link to this callback children(cache, opts) View Source
children(cache(), opts()) :: [Supervisor.Spec.spec()]

Returns the children specs that starts the adapter process.

Link to this callback delete(cache, key, opts) View Source
delete(cache(), key(), opts()) :: return() | no_return()

Deletes a single object from Cache.

See Nebulex.Cache.delete/2.

Link to this callback flush(cache) View Source
flush(cache()) :: :ok | no_return()

Flushes the cache.

See Nebulex.Cache.flush/0.

Link to this callback get(cache, key, opts) View Source
get(cache(), key(), opts()) :: nil | return() | no_return()

Retrieves a single object from Cache.

See Nebulex.Cache.get/2.

Link to this callback get_and_update(cache, key, function, opts) View Source
get_and_update(cache(), key(), (value() -> {get, update} | :pop), opts()) ::
  no_return() |
  {get, update} when get: value(), update: value()

Gets the value from key and updates it, all in one pass.

See Nebulex.Cache.get_and_update/3.

Link to this callback has_key?(cache, key) View Source
has_key?(cache(), key()) :: boolean()

Returns whether the given key exists in Cache.

See Nebulex.Cache.has_key/2.

Returns all cached keys.

See Nebulex.Cache.keys/0.

Link to this callback pop(cache, key, opts) View Source
pop(cache(), key(), opts()) :: return() | no_return()

Returns and removes a single object from Cache if key exists, otherwise returns nil.

See Nebulex.Cache.pop/2.

Link to this callback reduce(cache, acc, reducer, opts) View Source
reduce(cache(), acc :: any(), reducer(), opts()) :: any()

Invokes reducer for each entry in the cache, passing the key, the return and the accumulator acc as arguments. reducer’s return value is stored in acc.

Returns the accumulator.

See Nebulex.Cache.reduce/2.

Link to this callback set(cache, key, value, opts) View Source
set(cache(), key(), value(), opts()) :: return() | no_return()

Stores a single object in the Cache.

See Nebulex.Cache.set/3.

Link to this callback size(cache) View Source
size(cache()) :: integer()

Returns the cache size (total number of cached entries).

See Nebulex.Cache.size/0.

Link to this callback to_map(cache, opts) View Source
to_map(cache(), opts()) :: map()

Returns a map with all cache entries.

See Nebulex.Cache.to_map/1.

Link to this callback update(cache, key, initial, function, opts) View Source
update(cache(), key(), initial :: value(), (value() -> value()), opts()) ::
  value() |
  no_return()

Updates the cached key with the given function.

See Nebulex.Cache.update/4.

Link to this callback update_counter(cache, key, incr, opts) View Source
update_counter(cache(), key(), incr :: integer(), opts()) ::
  integer() |
  no_return()

Updates (increment or decrement) the counter mapped to the given key.

See Nebulex.Cache.update_counter/3.