Simpler Cache v0.1.7 SimplerCache View Source
Simple cache implementation with no complicated features or locks.
Link to this section Summary
Functions
Deletes item from cache or does no-op
Returns an item from cache or nil if not found
Gets or stores an item based on a passed in function if the item is near expiry it will also update the cache and ttl to avoid thundering herd issues
Inserts new item into cache
Inserts new item or overwrites old item’s value
Sets the ttl to a specific value in ms greater than 0 for an item
Returns the number of elements in the cache
Updates existing value in cache based on old value and resets the timer Warning the below may retry a bit on heavy contention
Link to this section Types
Link to this section Functions
Deletes item from cache or does no-op
Returns an item from cache or nil if not found
get_or_store(any(), fallback_function(), pos_integer()) :: any()
Gets or stores an item based on a passed in function if the item is near expiry it will also update the cache and ttl to avoid thundering herd issues
insert_new(any(), any(), pos_integer()) :: {:ok, :inserted} | {:error, :item_is_in_cache} | {:error, any()}
Inserts new item into cache
put(any(), any(), pos_integer()) :: {:ok, :inserted} | {:error, any()}
Inserts new item or overwrites old item’s value
set_ttl_ms(any(), pos_integer()) :: {:ok, :updated} | {:error, :failed_to_update_element} | {:error, :element_not_found} | {:error, any()}
Sets the ttl to a specific value in ms greater than 0 for an item
Returns the number of elements in the cache
update_existing(any(), update_function()) :: {:ok, :updated} | {:error, :failed_to_find_entry}
Updates existing value in cache based on old value and resets the timer Warning the below may retry a bit on heavy contention