Cache::Memory(3pm)

πŸ“¦
version 2.11 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

okay so Cache::Memory β€” it's the memory-based implementation of the Cache interface bestie!! that's the whole vibe. it lives in the Cache::Memory manual page (3pm), user contributed perl docs, you know the drill ✨


✨ SYNOPSIS ✨

like, literally the bare minimum to get going:

use Cache::Memory;

my $cache = Cache::Memory->new( namespace => 'MyNamespace',
                                default_expires => '600 sec' );

and for the full usage tea, go read Cache β€” the synopsis lives there 🫢


🌸 DESCRIPTION 🌸

so Cache::Memory implements the Cache interface. no cap. and here's the thing: this cache stores data on a per-process basis. it's giving speed demon because it is the fastest of the cache implementations πŸ”₯ but bestie… it's memory intensive 😭 and the data can not be shared between processes. it also does not persist after the process dies πŸ’€

BUT β€” and this is the part where she ate β€” the data will remain in the cache until cleared or it expires ✨ and it gets shared between instances of the cache object, so a cache object going out of scope will not destroy the data. iconic behaviour honestly πŸ‘‘


πŸŽ€ CONSTRUCTOR πŸŽ€

my $cache = Cache::Memory->new( %options )

the constructor takes cache properties as named arguments, like so:

my $cache = Cache::Memory->new( namespace => 'MyNamespace',
                                default_expires => '600 sec' );

peep the PROPERTIES section below (and the Cache documentation) for the full list of every property you can set πŸ’…


πŸ¦‹ METHODS πŸ¦‹

go read Cache for the API documentation, that's where the whole method menu lives ✨


πŸ’œ PROPERTIES πŸ’œ

Cache::Memory adds the property 'namespace' β€” which lets you specify a different caching store area to use instead of the default. and listen: all methods will work ONLY on the namespace specified. periodt.

my $ns = $c->namespace();
$c->set_namespace( $namespace );

for additional properties, check the Cache documentation 🫢


🌈 SEE ALSO 🌈

  • Cache

πŸ‘‘ AUTHOR πŸ‘‘

  • Chris Leishman <chris@leishman.org>
  • Based on work by DeWitt Clinton <dewitt@unto.net>

Copyright (C) 2003-2006 Chris Leishman.  All Rights Reserved.

this module is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or implied. this program is free software; you can redistribute or modify it under the same terms as Perl itself πŸ’–

$Id: Memory.pm,v 1.9 2006/01/31 15:23:58 caleishm Exp $
ngl the "AS IS" / no-warranty bit is the real one β€” take it seriously even though we're being cute about it πŸ™ˆ

okay bestie that's the whole page, love u, go cache responsibly πŸ“πŸ§š this was Cache::Memory from the perl v5.34.0 docs, dated 2022-06-09, and yes she's serving Cache::Memory(3pm) energy the entire time πŸ’…βœ¨ mwah πŸ’–

πŸ“¦ where this page comes from