Tie::FileLRUCache

Tie::FileLRUCache is a lightweight but robust filesystem based persistent LRU cache.
Download

Tie::FileLRUCache Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Benjamin Franz
  • Publisher web site:
  • http://www.nihongo.org/snowhare/utilities/ftpweblog/

Tie::FileLRUCache Tags


Tie::FileLRUCache Description

Tie::FileLRUCache is a lightweight but robust filesystem based persistent LRU cache. Tie::FileLRUCache is a lightweight but robust filesystem based persistent LRU cache.SYNOPSISOBJECT INTERFACE use Tie::FileLRUCache; my $cache = Tie::FileLRUCache->new({ -cache_dir => $directory, -keep_last => 100 }); # Inserting value into LRU cache using '-key' $cache->update({ -key => $key, -value => $value }); # Inserting value into LRU cache using '-cache_key' my $cache_key = $cache->make_cache_key({ -key => $key }); $cache->update({ -cache_key => $cache_key, -value => $value }); # Checking LRU cache my ($in_cache,$value) = $cache->check({ -key => $key }); if ($in_cache) { return $value; } # Not in cache - do something else # Checking LRU cache with speed up hack for objects, hashes, arrays etc used as keys my $cache_key = $cache->make_cache_key({ -key => $something }); my ($in_cache,$value) = $cache->check({ -cache_key => $cache_key }); if ($in_cache) { return $value; } # Not in cache - do something else # Deleting a key and its value from the cache $cache->delete({ -key => $key }); # Clearing LRU cache $cache->clear;TIED INTERFACE use Tie::FileLRUCache; tie %hash, 'Tie::FileLRUCache', $cache_dir, $keep_last_n; # Adding a key/value to the cache $hash{$key} = $value; # Checking the cache if (not exists $hash{$key}) {; # No match . . . } else { my $value = $hash{$key}; . . . } # Removing a value from the cache; delete $hash{$key}; # Clearing the cache %hash = ();Note: Iteration over the cache (each, keys, values) is _NOT_ supported.Requirements:· PerlWhat's New in This Release:· Changes to pod tests to make them more CPANTS friendly.· No functional changes.


Tie::FileLRUCache Related Software