Arch::...edIndex(3pm)
π Arch::SharedIndex β a synchronized data structure (map) for IPC π
okay bestie, so this is Arch::...edIndex(3pm) from the User Contributed Perl Documentation, and it's genuinely one of those pages that sounds scary but is actually just a shared map that multiple processes can poke at without stepping on each other. it's giving "group project but everyone actually communicates". β¨
πΈ NAME πΈ
Arch::SharedIndex β a synchronized data structure (map) for IPC π
π¦ SYNOPSIS π¦
use Arch::SharedIndex;
my $map = Arch::SharedIndex->new(file => "/tmp/logintimes.idx");
my $time = time;
$map->store(migo => $time - 75, bob => $time - 5, enno => $time);
printf "All users: %s, %s, %s\n", $map->keys;
printf "New users: %s\n", $map->grep(sub { $_[1] == $time });
printf "Login time of migo: %s\n", $map->fetch('migo');
$map->update(sub { $_[1] + 10 }, sub { $_[1] == $time });
$map->store(migo => $time);
$map->delete('bob');
printf "Logged users with times: (%s)\n", join(", ", $map->hash);
look at her go π she's just a little map, storing, fetching, deleting, updating, living her best life.
π DESCRIPTION π
Arch::SharedIndex hands you a key-value map that can be shared and accessed safely by multiple processes at the same time. no fighting, no corrupted vibes, just synchronized IPC. periodt. π
π METHODS π
here's the whole lineup, no skips:
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.
β¨ new options β¨
Make a brand new index object. option is a hash of parameters. slay.
fileβ the path of the index file, used to store data. Must not be omitted. like, this one is not optional bestie, she's mandatory fr fr.can_createβ whether the index file gets automatically created. Defaults to1.max_sizeβ maximum number of entries in the index. Defaults to0(no limit). the sky's the limit, literally.expirationβ timeout in seconds, after which unused entries are removed. Defaults to0(don't expire entries).time_renewalβ whether fetching values resets the entry expiration timeout. Defaults to1ifmax_sizeis set,0otherwise.perl_dataβ whether non-scalar perl data can be stored. If true, values are encoded usingData::Dumper.perl_data_indentβ indent value forData::Dumperwhenperl_datais set. Defaults to0.perl_data_pairβ pair value forData::Dumperwhenperl_datais set. Defaults to"=>".
π the rest of the methods π
encode_value refβ Encode the value referenced by ref in a string representation. The encoding is done in place. yes queen, in place, no copies.decode_value refβ Decode a value encoded withencode_valuefrom its string representation. The decoding is done in place too.store_value key token valueβ 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_value key tokenβ Fetch the value stored for the given key and token. Sub-classes should implement this method.delete_value key tokenβ Delete a value stored for the given key and value. Sub-classes should implement this method.store kvpβ Store a set of key-value pairs. kvp may either be a reference to a hash or array, or list of keys and values.fetch keysβ Fetch values stored for a list of keys. keys may either be an array reference, or a list of keys.delete keysβ Delete values stored for a list of keys. keys may either be an array reference, or a list of keys.fetch_store mapfunc keysβ This is an optimized (fetch or store) in a single step. Fetch values stored for keys, just likefetch, 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. two birds, one iconic stone π¦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. iykyk π₯
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.grep predicateβ 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.filter predicateβ Deletes every entry 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. π she's deleting, bestie.update mapfunc predicateβ 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_list codeβ 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. the backstage main character π
π BUGS π
Awaiting for your reports. please send them, she's waiting, she's literally so patient π
π«Ά AUTHORS π«Ά
- Mikhael Goikhman (
migo@homemail.com--Perl-GPL/arch-perl--devel). - Enno Cramer (
uebergeek@web.de--2003/arch-perl--devel).
π SEE ALSO π
For more information, see Arch::SharedCache. β¨
and that's the whole page, bestie π§ this was perl v5.20.2, dated 2005-09-17 β vintage, iconic, still slaying π ππ
π¦ where this page comes from
- ubuntu jammy: libarch-perl 0.5.2-2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms