Cache.ConCache (elixir_cache v0.3.11)

View Source

ETS Based cache https://github.com/sasa1977/con_cache

Takes the following options:

  • :acquire_lock_timeout (pos_integer/0) - The default value is 5000.

  • :touch_on_read (boolean/0) - The default value is false.

  • :global_ttl - The default value is 1800000.

  • :ttl_check_interval - The default value is 60000.

  • :dirty? (boolean/0) - Use dirty_put instead of locking to put, enabled by default The default value is true.

  • :ets_options - https://www.erlang.org/doc/man/ets.html#new-2

Summary

Functions

Implements a version of get_or_store that locks locally so only one process runs store_fun at a time.

Types

ets_option()

@type ets_option() ::
  :named_table
  | :compressed
  | {:heir, pid()}
  | {:write_concurrency, boolean()}
  | {:read_concurrency, boolean()}
  | :ordered_set
  | :set
  | :bag
  | :duplicate_bag
  | {:name, atom()}

opts()

@type opts() :: [
  name: atom(),
  pid: pid(),
  global_ttl: non_neg_integer() | :infinity,
  acquire_lock_timeout: pos_integer(),
  touch_on_read: boolean() | nil,
  ttl_check_interval: non_neg_integer() | false,
  ets_options: [ets_option()]
]

Functions

dirty_get_or_store(cache_name, key, store_fun)

get_or_store(cache_name, key, ttl, store_fun)

Implements a version of get_or_store that locks locally so only one process runs store_fun at a time.

Any other processes that miss cache will wait for the first caller to finish store_fun then will read the result from cache.