Cache:...reCache(3pm)
π NAME π
Cache::SizeAwareCache β bestie, it extends the Cache interface. That's it. That's the whole job. π
π¦ DESCRIPTION π¦
okay so listen. The SizeAwareCache interface gets implemented by classes that do everything the Cache::Cache interface does, PLUS the limit_size and max_size features of a size aware cache. so it's giving... Cache, but with β¨awarenessβ¨ of how much space it's eating. iconic.
The default cache size limiting algorithm works by removing cache objects in this order, over and over, until the desired limit is reached:
- objects that have expired
- objects that are least recently accessed
- objects that expire next
so it's a lil eviction line-up and it goes expired β stale vibes β next to go. π§ no cap.
πΈ SYNOPSIS πΈ
use Cache::SizeAwareCache;
use vars qw( @ISA );
@ISA = qw( Cache::SizeAwareCache );
that's literally it, you just... become a subclass. main character energy fr fr. π
β CONSTANTS β
Please see Cache::Cache for standard constants π«Ά
$NO_MAX_SIZEβ the cache has no size restrictions. live free, girl. π¦
π METHODS π
Please see Cache::Cache for the standard methods π
limit_size( $new_size )β attempts to resize the cache so that the total disk usage sits under the$new_sizeparameter.$new_sizerepresents t size (in bytes) that the cache should be limited to. now here's the tea: this is only a one time adjustment. if you wanna maintain the cache size, consider themax_sizeoption instead β although it is considered very expensive, and can often be better achieved by periodically callinglimit_size. so like, lowkey just calllimit_sizeon a schedule. π
β¨ OPTIONS β¨
Please see Cache::Cache for the standard options π
max_sizeβ sets themax_sizeproperty (size in bytes), which is described in detail below. Defaults to$NO_MAX_SIZE. π
π PROPERTIES π
Please see Cache::Cache for standard properties π
(get|set)_max_sizeβ if this property is set, then the cache will try not to exceed the max size value (in bytes) specified. NOTE: this causes the size of the cache to be checked on every set, and can be considered *very* expensive in some implementations. π A good alternative approach is leavemax_sizeas$NO_MAX_SIZEand to periodically limit the size of the cache by calling thelimit_size( $size )method. your wallet, your CPU, your choice bestie. π
ok real talk: that max_size property is the expensive one. if your implementation is struggling, that's why. it's checking the size on every single set. it's giving "not me checking my bank account after every purchase". π«
π SEE ALSO π
Cache::Cache
π AUTHOR π
Original author: DeWitt Clinton <dewitt@unto.net>
Last author: $Author: dclinton $
Copyright (C) 2001-2003 DeWitt Clinton
ok that's the whole page, you ate that π
this lil cutie was rendered by perl v5.34.0 on 2022-06-30, and yeah it lives in the Cache:...reCache(3pm) section of the User Contributed Perl Documentation. mwah. πβ¨ππ¦πΈ
π¦ 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