Cache::LRU(3pm)

Cache::LRU3pm

A simple, fast implementation of lru cache in pure perl

Usage

    use Cache::LRU;
    my $cache = Cache::LRU->new(
        size => $max_num_of_entries,
    );
    $cache->set($key => $value);
    $value = $cache->get($key);
    $removed_value = $cache->remove($key);

Overview

Cache::LRU is a simple, fast implementation of an in-memory LRU cache in pure perl.

Functions

Cache::LRU->new(size => $max_num_of_entries)

Creates a new cache object. Takes a hash as the only argument. The only parameter currently recognized is the "size" parameter that specifies the maximum number of entries to be stored within the cache object.

$cache->get($key)

Returns the cached object if exists, or undef otherwise.

$cache->set($key => $value)

Stores the given key-value pair.

$cache->remove($key)

Removes data associated to the given key and returns the old value, if any.

$cache->clear($key)

Removes all entries from the cache.

Releases

5 releases since Debian 9 (Stretch); the text changed 3 times.

  1. 9–10
  2. 11
  3. 12
  4. 13

Author

Kazuho Oku

License

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See <http://www.perl.com/perl/misc/Artistic.html>

From libcache-lru-perl 0.04-4 in Debian 13 (Trixie). Parsed by carta from the page's man source.