Skip to content
Simple, fast implementation of LRU cache in pure perl
Raku
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/Cache
t
.travis.yml
META6.json
README.md

README.md

perl6-Cache-LRU - Simple, fast implementation of LRU cache in pure perl

Build Status

SYNOPSIS

use Cache::LRU;

my $cache = Cache::LRU.new(size => 1024);

$cache.set($key, $value);
# Or $cache{$key} = $value

my $value = $cache.get($key);

my $removed_value = $cache.remove($key);
# Or $cache{$key}:delete

DESCRIPTION

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

This class implements the associative interface, so in most cases it can be used as a regular Hash.

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. size is default 1024.

$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.

You can’t perform that action at this time.