Cache::LRU(3)

πŸ¦‹ Cache::LRU(3) β€” the pure-perl LRU cache that's lowkey iconic πŸ¦‹

Okay bestie, this is the Cache::LRU(3) page from User Contributed Perl Documentation, and it's giving β€œsimple, fast, in-memory LRU cache, written in pure perl.” No cap. Let's get into it. πŸ’…

NAME πŸŽ€

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

SYNOPSIS ✨

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);

DESCRIPTION 🌸

Cache::LRU is a simple, fast implementation of an in-memory LRU cache in pure perl. That's the whole vibe: it caches stuff in memory, it does LRU things, and it's pure perl. Periodt. πŸ’–

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, which specifies the maximum number of entries to be stored within the cache object. Slay. 🫢

$cache->get($key) πŸ”

Returns the cached object if it exists, or undef otherwise. That's it. That's the function. πŸ’…

$cache->set($key => $value) πŸ“₯

Stores the given key-value pair. Very demure, very mindful. πŸŽ€

$cache->remove($key) πŸ—‘οΈ

Removes data associated to the given key and returns the old value, if any. So you get the ex-content back, iykyk. πŸ’€

$cache->clear($key) 🧹

Removes all entries from the cache. Yes, the signature says $cache->clear($key); the job is still β€œnuke every entry.” No notes. 😭

AUTHOR πŸ‘‘

Kazuho Oku. Iconic behavior. 🌟

SEE ALSO πŸ‘€

  • Cache
  • Cache::Ref
  • Tie::Cache::LRU

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>


πŸ’– That's the whole manual, bestie! This cutie is Cache::LRU(3), brought to you by perl v5.42.0 and dated 2024-03-04. Go forth and cache responsibly. πŸŽ€βœ¨

πŸ“¦ where this page comes from