---
name: "Cache::SizeAwareCache"
section: "3pm"
platform: "linux"
package: "libcache-cache-perl"
version: "1.08-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Cache::SizeAwareCache"
---

# Cache::SizeAwareCache(3pm)

## NAME

Cache::SizeAwareCache -- extends the Cache interface.

## DESCRIPTION

The SizeAwareCache interface is implemented by classes that support all of the Cache::Cache interface in addition to the limit\_size and max\_size features of a size aware cache.

The default cache size limiting algorithm works by removing cache objects in the following order until the desired limit is reached:

```
  1) objects that have expired
  2) objects that are least recently accessed
  3) objects that expire next
```

## SYNOPSIS

```
  use Cache::SizeAwareCache;
  use vars qw( @ISA );
  @ISA = qw( Cache::SizeAwareCache );
```

## CONSTANTS

Please see Cache::Cache for standard constants

- *$NO\_MAX\_SIZE*

  The cache has no size restrictions

## METHODS

Please see Cache::Cache for the standard methods

- **limit\_size( $new\_size )**

  Attempt to resize the cache such that the total disk usage is under the *$new\_size* parameter.  *$new\_size* represents t size (in bytes) that the cache should be limited to.  Note that this is only a one time adjustment.  To maintain the cache size, consider using the *max\_size* option, although it is considered very expensive, and can often be better achieved by periodically calling *limit\_size*.

## 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.

## SEE ALSO

Cache::Cache

## AUTHOR

Original author: DeWitt Clinton \<dewitt@unto.net\>

Last author:     `$Author:` dclinton $

Copyright (C) 2001-2003 DeWitt Clinton
