Module z_depcache

Simple caching server with dependency checks and local in process memoization of lookups.

Copyright © 2009-2010 Marc Worrell

Behaviours: gen_server.

Authors: Marc Worrell (marc@worrell.nl).

Description

Simple caching server with dependency checks and local in process memoization of lookups.

Function Index

cleanup/4Cleanup process for the depcache.
cleanup/8
code_change/3
flush/1Flush all keys from the caches.
flush/2Flush the key and all keys depending on the key.
flush_process_dict/0Flush all items memoized in the process dictionary.
get/2Fetch the key from the cache, return the data or an undefined if not found (or not valid).
get/3Fetch the key from the cache, return the data or an undefined if not found (or not valid).
get_subkey/3Fetch the key from the cache, return the data or an undefined if not found (or not valid).
get_wait/2Fetch the key from the cache, when the key does not exist then lock the entry and let the calling process insert the value.
handle_call/3Return the ets tables used by the cache.
handle_cast/2
handle_info/2
in_process/0Check if we use a local process dict cache.
in_process/1Enable or disable the in-process caching using the process dictionary.
init/1Initialize the depcache.
memo/2
memo/3
memo/4
memo/5
set/3Add the key to the depcache, hold it for 3600 seconds and no dependencies.
set/4Add the key to the depcache, hold it for MaxAge seconds and no dependencies.
set/5Add the key to the depcache, hold it for MaxAge seconds and check the dependencies.
size/1Return the total memory size of all stored terms.
start_link/1
terminate/2
tick/1Periodic tick used for incrementing the clock.

Function Details

cleanup/4

cleanup(Pid, MetaTable, DepsTable, DataTable) -> any()

Cleanup process for the depcache. Periodically checks a batch of depcache items for their validity. Asks the depcache server to delete invalidated items. When the load of the data table is too high then This cleanup process starts to delete random entries. By using a random delete we don't need to keep a LRU list, which is a bit expensive.

cleanup/8

cleanup(Pid, MetaTable, DepsTable, DataTable, SlotNr, Now, Mode, Ct) -> any()

code_change/3

code_change(OldVersion, State, Extra) -> any()

flush/1

flush(Context::#context{}) -> void()

Flush all keys from the caches

flush/2

flush(Key, Context::#context{}) -> void()

Flush the key and all keys depending on the key

flush_process_dict/0

flush_process_dict() -> any()

Flush all items memoized in the process dictionary.

get/2

get(Key, Context) -> {ok, Data} | undefined

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

get/3

get(Key, SubKey, Context) -> {ok, Data} | undefined

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

get_subkey/3

get_subkey(Key, SubKey, Context) -> {ok, Data} | undefined

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

get_wait/2

get_wait(Key, Context) -> {ok, Data} | undefined

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.

handle_call/3

handle_call(X1, From, State) -> any()

Return the ets tables used by the cache

handle_cast/2

handle_cast(Msg, State) -> any()

handle_info/2

handle_info(Msg, State) -> any()

in_process/0

in_process() -> any()

Check if we use a local process dict cache

in_process/1

in_process(X1) -> any()

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

init/1

init(SiteProps) -> {ok, State}

Initialize the depcache. Creates ets tables for the deps, meta and data. Spawns garbage collector.

memo/2

memo(Function, Context) -> any()

memo/3

memo(Function, MaxAge, Context) -> any()

memo/4

memo(F, Key, MaxAge, Context) -> any()

memo/5

memo(F, Key, MaxAge, Dep, Context) -> any()

set/3

set(Key, Data, Context) -> void()

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

set/4

set(Key, Data, MaxAge, Context) -> void()

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

set/5

set(Key, Data, MaxAge, Depend, Context) -> void()

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

size/1

size(Context::#context{}) -> int()

Return the total memory size of all stored terms

start_link/1

start_link(SiteProps) -> any()

terminate/2

terminate(Reason, State) -> any()

tick/1

tick(Context::#context{}) -> none()

Periodic tick used for incrementing the clock


Generated by EDoc, Feb 25 2011, 21:14:41.