chunky v0.13.0 Chunky.CacheAgent View Source

The CacheAgent is a dead simple wrapper of an atom named Agent around a Map.

Start an agent for a particular function cache within the current BEAM instance with:

iex> CacheAgent.start_link(:function_name)

Check for values with has?/2:

iex> CacheAgent.has?(:function_name, 3)

Get and set values with get/2 and set/3:

iex> CacheAgent.set(:function_name, 3, 3235)
iex> CacheAgent.get(:function_name, 3)
3235

See Math.partition_count/1 as an example.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Retrieve a value from the cache by key.

Check if the cache has a key

Store a key/value pair in the cache.

Start a cache for a particular atom. Calling multiple times with the same atom will return the original named cache, and isn't harmful.

Link to this section Functions

Link to this macro

cache_as(name, key, list)

View Source (macro)

Returns a specification to start this module under a supervisor.

See Supervisor.

Retrieve a value from the cache by key.

Check if the cache has a key

Store a key/value pair in the cache.

Start a cache for a particular atom. Calling multiple times with the same atom will return the original named cache, and isn't harmful.