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:

  1. objects that have expired
  2. objects that are least recently accessed
  3. 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_size parameter. $new_size represents 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 the max_size option instead β€” although it is considered very expensive, and can often be better achieved by periodically calling limit_size. so like, lowkey just call limit_size on a schedule. 😌

✨ OPTIONS ✨

Please see Cache::Cache for the standard options 🌈

  • max_size β€” sets the max_size property (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 leave max_size as $NO_MAX_SIZE and to periodically limit the size of the cache by calling the limit_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