z_depcache (zotonic_core v1.0.0-rc.17)

z_depcache interface file for handing depcache functions from the Zotonic context.

Summary

Functions

Flush all keys from the caches

Flush the key and all keys depending on the key

Flush all items memoized in the process dictionary.

Fetch the key from the cache, return the data or an undefined if not found (or not valid)

Fetch the key from the cache, return the data or an undefined if not found (or not valid)

Fetch the key from the cache, return the data or an undefined if not found (or not valid)

Fetch the key from the cache, when the key does not exist then lock the entry and let the calling process insert the value. All other processes requesting the key will wait till the key is updated and receive the key's new value.

Enable or disable the in-process caching using the process dictionary

Check if we use a local process dict cache

Add the key to the depcache, hold it for 3600 seconds and no dependencies

Add the key to the depcache, hold it for MaxAge seconds and no dependencies

Add the key to the depcache, hold it for MaxAge seconds and check the dependencies

Return the total memory size of all stored terms

Start depcache instance based on site configuration

Functions

flush(Context)

-spec flush(Context) -> ok when Context :: z:context().

Flush all keys from the caches

flush(Key, Context)

-spec flush(Key, Context) -> ok when Key :: any(), Context :: z:context().

Flush the key and all keys depending on the key

flush_process_dict()

-spec flush_process_dict() -> ok.

Flush all items memoized in the process dictionary.

get(Key, Context)

-spec get(Key, Context) -> {ok, Data} | undefined
             when Key :: any(), Context :: z:context(), Data :: any().

Fetch the key from the cache, return the data or an undefined if not found (or not valid)

get(Key, SubKey, Context)

-spec get(Key, SubKey, Context) -> {ok, Data} | undefined
             when Key :: any(), SubKey :: any(), Context :: z:context(), Data :: any().

Fetch the key from the cache, return the data or an undefined if not found (or not valid)

get_subkey(Key, SubKey, Context)

-spec get_subkey(Key, SubKey, Context) -> {ok, Data} | undefined
                    when Key :: any(), SubKey :: any(), Context :: z:context(), Data :: any().

Fetch the key from the cache, return the data or an undefined if not found (or not valid)

get_wait(Key, Context)

-spec get_wait(Key, Context) -> Result
                  when
                      Key :: any(),
                      Context :: z:context(),
                      Data :: any(),
                      Result :: {ok, Data} | undefined | {throw, term()} | {error, term()}.

Fetch the key from the cache, when the key does not exist then lock the entry and let the calling process insert the value. All other processes requesting the key will wait till the key is updated and receive the key's new value.

in_process(Flag)

-spec in_process(boolean() | undefined) -> boolean() | undefined.

Enable or disable the in-process caching using the process dictionary

in_process_server(Server)

-spec in_process_server(Server) -> boolean() when Server :: pid() | atom().

Check if we use a local process dict cache

memo(Function, Context)

memo(Function, MaxAge, Context)

memo(F, Key, MaxAge, Context)

memo(F, Key, MaxAge, Dep, Context)

record_depcache_event(Event, Host)

set(Key, Data, Context)

-spec set(Key, Data, Context) -> ok when Key :: any(), Data :: any(), Context :: z:context().

Add the key to the depcache, hold it for 3600 seconds and no dependencies

set(Key, Data, MaxAge, Context)

-spec set(Key, Data, MaxAge, Context) -> ok
             when Key :: any(), Data :: any(), MaxAge :: non_neg_integer(), Context :: z:context().

Add the key to the depcache, hold it for MaxAge seconds and no dependencies

set(Key, Data, MaxAge, Depend, Context)

-spec set(Key, Data, MaxAge, Depend, Context) -> ok
             when
                 Key :: any(),
                 Data :: any(),
                 MaxAge :: non_neg_integer(),
                 Depend :: [Key],
                 Context :: z:context().

Add the key to the depcache, hold it for MaxAge seconds and check the dependencies

size(Context)

-spec size(Context) -> non_neg_integer() | undefined when Context :: z:context().

Return the total memory size of all stored terms

start_link(SiteProps)

Start depcache instance based on site configuration