Gamend.Cache (gamend_core v1.0.1192)

Copy Markdown View Source

Application cache backed by Nebulex.

This cache uses a 2-level (near-cache) topology via Nebulex.Adapters.Multilevel:

Summary

Functions

Increments the version counter at key and broadcasts the bump so every other app instance increments its local copy too (see Gamend.Cache.Sync).

Cache-through helper: returns the cached value for key, or computes and caches the result of fun.

Callback implementation for Nebulex.Cache.delete/2.

Callback implementation for Nebulex.Cache.delete!/2.

Callback implementation for Nebulex.Cache.fetch/2.

Callback implementation for Nebulex.Cache.fetch!/2.

A convenience function to get the cache inclusion policy.

Deletes key on this node (all cache levels) and broadcasts the deletion so every other app instance evicts the key from its local L1 (see Gamend.Cache.Sync).

PubSub topic that invalidate/1 broadcasts on.

Callback implementation for Nebulex.Cache.put/3.

Callback implementation for Nebulex.Cache.put!/3.

Callback implementation for Nebulex.Cache.take/2.

Callback implementation for Nebulex.Cache.take!/2.

Callback implementation for Nebulex.Cache.touch/2.

Callback implementation for Nebulex.Cache.touch!/2.

Callback implementation for Nebulex.Cache.ttl/2.

Callback implementation for Nebulex.Cache.ttl/3.

Callback implementation for Nebulex.Cache.ttl!/2.

Functions

bump_version(key)

@spec bump_version(term()) :: :ok

Increments the version counter at key and broadcasts the bump so every other app instance increments its local copy too (see Gamend.Cache.Sync).

Version-keyed caches embed the counter in their data keys, so any change to the counter forces a fresh recompute on the next read. Remote nodes apply a bump rather than a delete: a delete would re-seed their counter at 1, which can collide with version values whose data entries are still inside a TTL, while a bump is monotonic per node.

cached(key, opts \\ [], fun)

@spec cached(term(), keyword(), (-> term())) :: term()

Cache-through helper: returns the cached value for key, or computes and caches the result of fun.

Cached nil results are honored — fun only runs on a real cache miss.

Options

  • :ttl — time-to-live in milliseconds

count_all(query_spec \\ [], opts \\ [])

Callback implementation for Nebulex.Cache.count_all/2.

count_all(dynamic_cache, query_spec, opts)

Callback implementation for Nebulex.Cache.count_all/3.

count_all!(query_spec \\ [], opts \\ [])

Callback implementation for Nebulex.Cache.count_all!/2.

count_all!(dynamic_cache, query_spec, opts)

Callback implementation for Nebulex.Cache.count_all!/3.

decr(key, amount \\ 1, opts \\ [])

Callback implementation for Nebulex.Cache.decr/3.

decr(dynamic_cache, key, amount, opts)

Callback implementation for Nebulex.Cache.decr/4.

decr!(key, amount \\ 1, opts \\ [])

Callback implementation for Nebulex.Cache.decr!/3.

decr!(dynamic_cache, key, amount, opts)

Callback implementation for Nebulex.Cache.decr!/4.

delete(key, opts \\ [])

Callback implementation for Nebulex.Cache.delete/2.

delete(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.delete/3.

delete!(key, opts \\ [])

Callback implementation for Nebulex.Cache.delete!/2.

delete!(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.delete!/3.

delete_all(query_spec \\ [], opts \\ [])

Callback implementation for Nebulex.Cache.delete_all/2.

delete_all(dynamic_cache, query_spec, opts)

Callback implementation for Nebulex.Cache.delete_all/3.

delete_all!(query_spec \\ [], opts \\ [])

Callback implementation for Nebulex.Cache.delete_all!/2.

delete_all!(dynamic_cache, query_spec, opts)

Callback implementation for Nebulex.Cache.delete_all!/3.

expire(key, ttl, opts \\ [])

Callback implementation for Nebulex.Cache.expire/3.

expire(dynamic_cache, key, ttl, opts)

Callback implementation for Nebulex.Cache.expire/4.

expire!(key, ttl, opts \\ [])

Callback implementation for Nebulex.Cache.expire!/3.

expire!(dynamic_cache, key, ttl, opts)

Callback implementation for Nebulex.Cache.expire!/4.

fetch(key, opts \\ [])

Callback implementation for Nebulex.Cache.fetch/2.

fetch(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.fetch/3.

fetch!(key, opts \\ [])

Callback implementation for Nebulex.Cache.fetch!/2.

fetch!(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.fetch!/3.

fetch_or_store(key, fun, opts \\ [])

Callback implementation for Nebulex.Cache.fetch_or_store/3.

fetch_or_store(dynamic_cache, key, fun, opts)

Callback implementation for Nebulex.Cache.fetch_or_store/4.

fetch_or_store!(key, fun, opts \\ [])

Callback implementation for Nebulex.Cache.fetch_or_store!/3.

fetch_or_store!(dynamic_cache, key, fun, opts)

Callback implementation for Nebulex.Cache.fetch_or_store!/4.

get(key, default \\ nil, opts \\ [])

Callback implementation for Nebulex.Cache.get/3.

get(dynamic_cache, key, default, opts)

Callback implementation for Nebulex.Cache.get/4.

get!(key, default \\ nil, opts \\ [])

Callback implementation for Nebulex.Cache.get!/3.

get!(dynamic_cache, key, default, opts)

Callback implementation for Nebulex.Cache.get!/4.

get_all(query_spec \\ [], opts \\ [])

Callback implementation for Nebulex.Cache.get_all/2.

get_all(dynamic_cache, query_spec, opts)

Callback implementation for Nebulex.Cache.get_all/3.

get_all!(query_spec \\ [], opts \\ [])

Callback implementation for Nebulex.Cache.get_all!/2.

get_all!(dynamic_cache, query_spec, opts)

Callback implementation for Nebulex.Cache.get_all!/3.

get_and_update(key, fun, opts \\ [])

Callback implementation for Nebulex.Cache.get_and_update/3.

get_and_update(dynamic_cache, key, fun, opts)

Callback implementation for Nebulex.Cache.get_and_update/4.

get_and_update!(key, fun, opts \\ [])

Callback implementation for Nebulex.Cache.get_and_update!/3.

get_and_update!(dynamic_cache, key, fun, opts)

Callback implementation for Nebulex.Cache.get_and_update!/4.

get_or_store(key, fun, opts \\ [])

Callback implementation for Nebulex.Cache.get_or_store/3.

get_or_store(dynamic_cache, key, fun, opts)

Callback implementation for Nebulex.Cache.get_or_store/4.

get_or_store!(key, fun, opts \\ [])

Callback implementation for Nebulex.Cache.get_or_store!/3.

get_or_store!(dynamic_cache, key, fun, opts)

Callback implementation for Nebulex.Cache.get_or_store!/4.

has_key?(key, opts \\ [])

Callback implementation for Nebulex.Cache.has_key?/2.

has_key?(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.has_key?/3.

in_transaction?(opts \\ [])

Callback implementation for Nebulex.Cache.in_transaction?/1.

in_transaction?(dynamic_cache, opts)

Callback implementation for Nebulex.Cache.in_transaction?/2.

inclusion_policy(name \\ __MODULE__)

A convenience function to get the cache inclusion policy.

incr(key, amount \\ 1, opts \\ [])

Callback implementation for Nebulex.Cache.incr/3.

incr(dynamic_cache, key, amount, opts)

Callback implementation for Nebulex.Cache.incr/4.

incr!(key, amount \\ 1, opts \\ [])

Callback implementation for Nebulex.Cache.incr!/3.

incr!(dynamic_cache, key, amount, opts)

Callback implementation for Nebulex.Cache.incr!/4.

info(spec \\ :all, opts \\ [])

Callback implementation for Nebulex.Cache.info/2.

info(dynamic_cache, spec, opts)

Callback implementation for Nebulex.Cache.info/3.

info!(spec \\ :all, opts \\ [])

Callback implementation for Nebulex.Cache.info!/2.

info!(dynamic_cache, spec, opts)

Callback implementation for Nebulex.Cache.info!/3.

invalidate(key)

@spec invalidate(term()) :: :ok

Deletes key on this node (all cache levels) and broadcasts the deletion so every other app instance evicts the key from its local L1 (see Gamend.Cache.Sync).

Use this instead of delete/1 whenever a stale read would be incorrect rather than merely briefly outdated — e.g. cached user structs that gate authentication (token_version) or account state (is_activated).

invalidation_topic()

@spec invalidation_topic() :: String.t()

PubSub topic that invalidate/1 broadcasts on.

put(key, value, opts \\ [])

Callback implementation for Nebulex.Cache.put/3.

put(dynamic_cache, key, value, opts)

Callback implementation for Nebulex.Cache.put/4.

put!(key, value, opts \\ [])

Callback implementation for Nebulex.Cache.put!/3.

put!(dynamic_cache, key, value, opts)

Callback implementation for Nebulex.Cache.put!/4.

put_all(entries, opts \\ [])

Callback implementation for Nebulex.Cache.put_all/2.

put_all(dynamic_cache, entries, opts)

Callback implementation for Nebulex.Cache.put_all/3.

put_all!(entries, opts \\ [])

Callback implementation for Nebulex.Cache.put_all!/2.

put_all!(dynamic_cache, entries, opts)

Callback implementation for Nebulex.Cache.put_all!/3.

put_new(key, value, opts \\ [])

Callback implementation for Nebulex.Cache.put_new/3.

put_new(dynamic_cache, key, value, opts)

Callback implementation for Nebulex.Cache.put_new/4.

put_new!(key, value, opts \\ [])

Callback implementation for Nebulex.Cache.put_new!/3.

put_new!(dynamic_cache, key, value, opts)

Callback implementation for Nebulex.Cache.put_new!/4.

put_new_all(entries, opts \\ [])

Callback implementation for Nebulex.Cache.put_new_all/2.

put_new_all(dynamic_cache, entries, opts)

Callback implementation for Nebulex.Cache.put_new_all/3.

put_new_all!(entries, opts \\ [])

Callback implementation for Nebulex.Cache.put_new_all!/2.

put_new_all!(dynamic_cache, entries, opts)

Callback implementation for Nebulex.Cache.put_new_all!/3.

register_event_listener(listener, opts \\ [])

Callback implementation for Nebulex.Cache.register_event_listener/2.

register_event_listener(dynamic_cache, listener, opts)

Callback implementation for Nebulex.Cache.register_event_listener/3.

register_event_listener!(listener, opts \\ [])

Callback implementation for Nebulex.Cache.register_event_listener!/2.

register_event_listener!(dynamic_cache, listener, opts)

Callback implementation for Nebulex.Cache.register_event_listener!/3.

replace(key, value, opts \\ [])

Callback implementation for Nebulex.Cache.replace/3.

replace(dynamic_cache, key, value, opts)

Callback implementation for Nebulex.Cache.replace/4.

replace!(key, value, opts \\ [])

Callback implementation for Nebulex.Cache.replace!/3.

replace!(dynamic_cache, key, value, opts)

Callback implementation for Nebulex.Cache.replace!/4.

stream(query_spec \\ [], opts \\ [])

Callback implementation for Nebulex.Cache.stream/2.

stream(dynamic_cache, query_spec, opts)

Callback implementation for Nebulex.Cache.stream/3.

stream!(query_spec \\ [], opts \\ [])

Callback implementation for Nebulex.Cache.stream!/2.

stream!(dynamic_cache, query_spec, opts)

Callback implementation for Nebulex.Cache.stream!/3.

take(key, opts \\ [])

Callback implementation for Nebulex.Cache.take/2.

take(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.take/3.

take!(key, opts \\ [])

Callback implementation for Nebulex.Cache.take!/2.

take!(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.take!/3.

touch(key, opts \\ [])

Callback implementation for Nebulex.Cache.touch/2.

touch(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.touch/3.

touch!(key, opts \\ [])

Callback implementation for Nebulex.Cache.touch!/2.

touch!(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.touch!/3.

transaction(fun, opts \\ [])

Callback implementation for Nebulex.Cache.transaction/2.

transaction(dynamic_cache, fun, opts)

Callback implementation for Nebulex.Cache.transaction/3.

ttl(key, opts \\ [])

Callback implementation for Nebulex.Cache.ttl/2.

ttl(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.ttl/3.

ttl!(key, opts \\ [])

Callback implementation for Nebulex.Cache.ttl!/2.

ttl!(dynamic_cache, key, opts)

Callback implementation for Nebulex.Cache.ttl!/3.

unregister_event_listener(id, opts \\ [])

Callback implementation for Nebulex.Cache.unregister_event_listener/2.

unregister_event_listener(dynamic_cache, id, opts)

Callback implementation for Nebulex.Cache.unregister_event_listener/3.

unregister_event_listener!(id, opts \\ [])

Callback implementation for Nebulex.Cache.unregister_event_listener!/2.

unregister_event_listener!(dynamic_cache, id, opts)

Callback implementation for Nebulex.Cache.unregister_event_listener!/3.

update(key, initial, fun, opts \\ [])

Callback implementation for Nebulex.Cache.update/4.

update(dynamic_cache, key, initial, fun, opts)

Callback implementation for Nebulex.Cache.update/5.

update!(key, initial, fun, opts \\ [])

Callback implementation for Nebulex.Cache.update!/4.

update!(dynamic_cache, key, initial, fun, opts)

Callback implementation for Nebulex.Cache.update!/5.