z_memo (zotonic_core v1.0.0-rc.17)

Simple memo functions. Stores much used values in the process dictionary. Especially useful for ACL lookups or often used functions. This is enabled for all HTTP and MQTT requests.

Summary

Functions

Delete a key from the cache. Return the previous value and 'undefined' if not set.

Disable memoization for this process, also cleans up the possible depcache memoization.

Enable memoization for this process. You need to call set_userid/1 before memoization is effective.

Enable memoization for this process, calls set_userid/1 for the given context.

Flush the memo cache and set the cache to the current user - needed when changing users

Check if the key is stored. Irrespective of current user-id or site context.

Check if the cache is enabled for the user and if the key is stored.

Fetch the current memo settings, used when copying the memo settings to a new process.

Check if memoization is enabled for the current user/process. Disabled when in a sudo action.

Store a key. Irrespective of current user-id or site context.

Store the value if enabled for the current user.

Set the memo settings from a previous get_status/0. Used when copying the memo settings to a new process.

If a new user id is set in the context, and the user is different from the previous user, then reset the memoization cache and start with the new user id.

Functions

delete(Key)

Delete a key from the cache. Return the previous value and 'undefined' if not set.

disable()

Disable memoization for this process, also cleans up the possible depcache memoization.

enable()

Enable memoization for this process. You need to call set_userid/1 before memoization is effective.

enable(Context)

Enable memoization for this process, calls set_userid/1 for the given context.

flush(Context)

Flush the memo cache and set the cache to the current user - needed when changing users

get(Key)

Check if the key is stored. Irrespective of current user-id or site context.

get(Key, Context)

Check if the cache is enabled for the user and if the key is stored.

get_status()

Fetch the current memo settings, used when copying the memo settings to a new process.

is_enabled(Context)

Check if memoization is enabled for the current user/process. Disabled when in a sudo action.

set(Key, Value)

Store a key. Irrespective of current user-id or site context.

set(Key, Value, Context)

Store the value if enabled for the current user.

set_status(_)

Set the memo settings from a previous get_status/0. Used when copying the memo settings to a new process.

set_userid(Context)

If a new user id is set in the context, and the user is different from the previous user, then reset the memoization cache and start with the new user id.