The following methods are available:
new, encode_value, decode_value, store_value, fetch_value, delete_value, store, fetch, delete,
fetch_store, keys, values, hash, list, grep, filter, update, query_index_list.
newoptions
Create a new index object. option is a hash of parameters.
file
The path of the index file, used to store data. Must not be omitted.
can_create
Whether the index file is automatically created. Defaults to 1.
max_size
Maximum number of entries in the index. Defaults to 0 (no limit).
expiration
Timeout in seconds after which unused entries are removed. Defaults to 0 (don't expire entries)
time_renewal
Whether fetching values resets the entry expiration timeout. Defaults to 1 if max_size is set, 0
otherwise.
perl_data
Whether non-scalar perl data can be stored. If true, values are encoded using Data::Dumper.
perl_data_indent
Indent value for Data::Dumper when perl_data is set. Defaults to 0.
perl_data_pair
Pair value for Data::Dumper when perl_data is set. Defaults to "=>".
encode_valueref
Encode the value referenced by ref in a string representation. The encoding is done in place.
decode_valueref
Decode a value encoded with encode_value from its string representation. The decoding is done in
place.
store_valuekeytokenvalue
Store a value for the given key and token. Create a new token if none is given. Returns the (new)
token. Sub-classes should implement this method.
fetch_valuekeytoken
Fetch the value stored for the given key and token. Sub-classes should implement this method.
delete_valuekeytoken
Delete a value stored for the given key and value. Sub-classes should implement this method.
storekvp
Store a set of key-value pairs. kvp may either be a reference to a hash or array, or list of keys
and values.
fetchkeys
Fetch values stored for a list of keys. keys may either be an array reference, or a list of keys.
deletekeys
Delete values stored for a list of keys. keys may either be an array reference, or a list of keys.
fetch_storemapfunckeys
This is an optimized (fetch or store) in a single step. Fetch values stored for keys, just like
fetch, but store values for the missing keys in the process. keys may be an array reference or a
list of keys. mapfunc will be called once for every key in keys that has no associated value, with
the key as its only argument. Its return value will be stored for that key.
keys
Returns a list of all valid keys. In scalar context, returns an array reference.
Keys are returned in no particular order, but values will return values in matching order if the
index has not been changed between calls.
values
Returns a list of all stored values. In scalar context, returns an array reference.
Values are returned in no particular order, but keys will return values in matching order if the
index has not been changed between calls.
hash
Returns the stored keys and values as a perl hash. In scalar context, returns hash reference.
list
Returns the stored keys and values as a list of pairs (array references with two elements each). In
scalar context, returns an array reference.
greppredicate
Returns a list of keys for which predicate returns a true value. predicate is called once for every
key, with the key and the stored value as its first and second argument.
filterpredicate
Deletes every entry for which predicate returns a true value. predicate is called once for every
key, with the key and the stored value asi its first and second argument.
updatemapfuncpredicate
Updates the value for every key for which predicate returns a true value with the return value from
mapfunc. Both predicate and mapfunc are called with the key and the stored values as their first and
second argument.
update_index_listcode
Synchronize access and call code with a reference to a list of pairs, each containing the key and
token, for every stored value.
Used internally by store, fetch, delete, fetch_store, keys, values, hash, list, grep, filter and
update.