Cache:...yCache(3pm)
π Cache::SharedMemoryCache π
okay so bestie, welcome to the perl docs, User Contributed Perl Documentation edition, and we're talking about Cache::SharedMemoryCache today π
β¨ NAME β¨
Cache::SharedMemoryCache β it extends the MemoryCache. that's the whole name, short and iconic, we love a concise queen π
πΈ DESCRIPTION πΈ
so here's the tea: SharedMemoryCache extends the MemoryCache class and binds the data store to shared memory so that separate processes can use the same cache. literally the whole point β multiple processes, one cache, sharing is caring π«Ά
but ngl, the official recommendation now is to use FileCache instead of SharedMemoryCache. not me being the bearer of bad news π here's why:
FileCacheprovides equal or better performance in all cases that we've been able to test. this is due to all modern OS's ability to buffer and cache file system accesses very well β like, they're genuinely so good at it β¨FileCachehas no real limits on cached object size or the number of cached objects, whereasSharedMemoryCachehas limits, and rather low ones at that π not the low limits bestieFileCacheworks well on every OS, whereasSharedMemoryCacheworks only on systems that supportIPC::ShareLite. andIPC::ShareLiteis an impressive effort β but think about how hard it is to get shared memory working properly on one system. now imagine writing a wrapper around shared memory for many operating systems. yeah. exactly. the audacity of that task is enormous π
π SYNOPSIS π
here's the vibe, copy-paste ready, no cap:
use Cache::SharedMemoryCache;
my %cache_options_= ( 'namespace' => 'MyNamespace',
'default_expires_in' => 600 );
my $shared_memory_cache =
new Cache::SharedMemoryCache( \%cache_options ) or
croak( "Couldn't instantiate SharedMemoryCache" );
look at that. 'namespace' set to 'MyNamespace', 'default_expires_in' set to 600, and if the constructor flops we croak with "Couldn't instantiate SharedMemoryCache" β dramatic and correct π
π¦ METHODS π¦
see Cache::Cache for the API documentation. that's where the actual method lore lives, iykyk π
π OPTIONS π
see Cache::Cache for the standard options. all the standard ones, over there, go look πΈ
π PROPERTIES π
see Cache::Cache for the default properties. yeah. also over there π§
β SEE ALSO β
Cache::CacheCache::MemoryCache
π AUTHOR π
- original author: DeWitt Clinton
<dewitt@unto.net> - last author:
$Author: dclinton $ - copyright (C) 2001-2003 DeWitt Clinton
okay and that's a wrap on this one π«Ά this page is from perl v5.34.0, dated 2022-06-30, and it's part of the User Contributed Perl Documentation besties. go forth and maybe use FileCache instead, fr fr πβ¨
π¦ where this page comes from
- debian bookworm: libcache-cache-perl 1.08-3 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- debian trixie: libcache-cache-perl 1.08-3 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- ubuntu noble: libcache-cache-perl 1.08-3 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- ubuntu resolute: libcache-cache-perl 1.08-3 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- ubuntu stonking: libcache-cache-perl 1.08-3 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms