Copyright © (C) 2011-2015, Jim Rosenblum
Version: May 24 2016 22:38:41
Authors: Jim Rosenblum.
Library module that manages the mnesia tables mapping Map and Key to a Value.
IT IS UP TO THE CALLER TO WRAP THESE FUNCTIONS IN THE APPROPRIATE MNESIA TRANSACTIONS
This module interacts with mnesia to persist and access keys in service of the jc module.
Up to four additional, indexed fields may be used to support faster evict_match and values_match operations. These operations only make sense for JSON values and look for Keys whose Values contain a specified value at a given 'path' within the JSON Value. That is, values_match and evict_match select or delete based on a 'path' criteria, such as "some.path.in.json.value=2". The additional fields, if used, are populated during a PUT operation -- the JSON Value is travesed for the target provided by the path criteria and the targetd value is put in an indxed field for fast look up in service of the values_match and evict_match operations.
{key_to_val, {Key, Map}, Map, Key, Value, i1, i2, i3, i4, ...} to_index contains a row for each {Map and JSON path to be indexed {to_index, {bed,{"some","path"}, bed, 6} the above record indicates that i1 (the 6th field) should be used to store the value at some.path in Values cached in the Bed map.key() = any()
key_to_value() = #key_to_value{jc_key = undefined | {key(), map_name()}, map = undefined | map_name(), key = undefined | key(), value = undefined | value(), i1 = undefined | value(), i2 = undefined | value(), i3 = undefined | value(), i4 = undefined | value(), create_tm = undefined | time_stamp(), last_update = undefined | time_stamp(), ttl_secs = undefined | ttl(), ref = undefined | rec_ref()}
map_name() = any()
rec_ref() = reference()
seconds() = non_neg_integer()
time_stamp() = seconds()
ttl() = seconds()
value() = any()
clear/1 | Clear all data for the given map. |
delete_record_by_ref/1 | Delete the cache element by its record reference. |
evict/2 | Evict Map/Key from the cache. |
flush/1 | Delete the entire cache with or without triggering notifications based on the parameter. |
fun_match/4 | Select those Map items whose JSON value, at the given path, equals Test and invoke the supplied function/4 with the Map, Key, Value and fold accumulator as parameters. |
get/2 | Return the #key_to_value{} which contains the data associated with Key and Key. |
get_map/1 | Return all the #key_to_value() for a given Map. |
get_map_since/2 | Return all the #key_to_value() for a given Map whose create_tm is older than now - AgeSecs. |
indexes/0 | |
indexes/1 | |
key_set/1 | Return all keys in the given cache Map. |
maps/0 | Return a sorted list of all maps currently in the cache. |
put/5 | Put the {link @map_name(). |
start_indexing/2 | Start using a custom, field for the value found in JSON Values at the path with respect to a given map. |
stats/1 | Return vairous stats information. |
stop_indexing/2 | Stop indexing Map entries with respect to the json path expressed as tuples: {"menu", "id"}, for example. |
up_nodes/0 |
clear(Map::map_name()) -> ok
Clear all data for the given map.
delete_record_by_ref(RecRef::rec_ref()) -> ok
Delete the cache element by its record reference. Used by eviction manager.
evict(Map::map_name(), Key::key()) -> ok
Evict Map/Key from the cache
flush(X1::silent | loud) -> ok
Delete the entire cache with or without triggering notifications based on the parameter.
fun_match(Map::map_name(), Paths::tuple(), Test::atom(), Fun::function()) -> [term()]
Select those Map items whose JSON value, at the given path, equals Test and invoke the supplied function/4 with the Map, Key, Value and fold accumulator as parameters.
get(Map::map_name(), Key::key()) -> {ok, key_to_value() | jc_miss}
Return the #key_to_value{} which contains the data associated with Key and Key.
get_map(Map::map_name()) -> {ok, [Results::key_to_value()]}
Return all the #key_to_value() for a given Map.
get_map_since(Map::map_name(), AgeSecs::seconds()) -> [Results::key_to_value()] | {error, module(), tuple() | bad_object}
Return all the #key_to_value() for a given Map whose create_tm is older than now - AgeSecs.
indexes() -> [{{map_name, tuple()}, Pos::non_neg_integer()}]
indexes(Map::map_name()) -> [{{map_name, tuple()}, Pos::non_neg_integer()}]
key_set(Map::map_name()) -> {ok, [Keys::key()]}
Return all keys in the given cache Map.
maps() -> [map_name()]
Return a sorted list of all maps currently in the cache.
put(Map::map_name(), Key::key(), Value::value(), TTL::ttl(), Ref::rec_ref()) -> {ok, {put, rec_ref()}}
Put the {link @map_name(). Map} and Key record. Return a tuple with a reference to the record so that an eviction timer can be created by the caller. IF THE PUT EVICTED AN ENTRY, JC_PSUB WILL DETECT THIS, CANCEL THE OLD TIMER AND RAISE THE EVENT TO SUBSCRIBERS.
start_indexing(Map::map_name(), Path::string() | binary()) -> ok | {error, no_indexes_available | any()}
Start using a custom, field for the value found in JSON Values at the path with respect to a given map. Start indexing the bed map with respect to "menu.id" - start_indexing(bed, "menu.id"}).
stats(X1::size | up) -> {size, [{TableNm::atom(), {records, RecCnt::non_neg_integer()}, {bytes, Words::non_neg_integer()}}]} | {uptime, term()} | {error, not_found | badarg}
Return vairous stats information. Currently size and uptime information.
stop_indexing(Map::map_name(), Path::string() | binary()) -> ok
Stop indexing Map entries with respect to the json path expressed as tuples: {"menu", "id"}, for example. If no one is using a custom field, stop indexing it.
up_nodes() -> [node()]
Generated by EDoc, May 24 2016, 22:38:41.