![]() |
![]()
| ![]() |
![]()
NAME"DocSet::Cache" - Maintain a Non-Volatile Cache of DocSet's Data SYNOPSISuse DocSet::Cache (); my $cache = DocSet::Cache->new($cache_path, 1); # $cache->read; # read by new() already $cache->write; # add a cache item to the ordered list $cache->add($id); # set/unset cached item's attributes $cache->set($id, $attr, $data); $cache->unset($id, $attr) # get cached item's attributes my $data = $cache->get($id, $attr); print "$id is cached" if $cache->is_cached($id); # invalidate cache (deletes all items) $cache->invalidate(); my $seq = $cache->id2seq($id); my $id = $cache->seq2id($seq); my @ids = $cache->ordered_ids; my $total_ids = $cache->total_ids; $cache->index_node( id => $id, stitle => $stitle, title => $title, abstract => $abstract, #... ); my %index_node = $cache->index_node(); $cache->parent_node($cache_path, $id, $rel_path); my ($cache_path, $id, $rel_path) = $cache->parent_node(); DESCRIPTION"DocSet::Cache" maintains a non-volatile cache of docset's data. The cache is initialized either from the freezed file at the provided path. When the file is empty or doesn't exists, a new cache is initialized. When the cache is modified it should be saved, but if for some reason it doesn't get saved, the "DESTROY" method will check whether the cache wasn't synced to the disk yet and will perform the sync itself. Each docset's node can create an entry in the cache, and store its data in it. The creator has to ensure that it supplies a unique id for each node that is added. Cache's internal representation is a hash, with internal data keys starting with _ (underscore), therefore the only restriction on node's id value is that it shouldn't not start with underscore. METHODSMETA: to be written (see SYNOPSIS meanwhile)
AUTHORSStas Bekman <stas (at) stason.org>
|