# perldoc > Cache::SizeAwareMemoryCache

---
type: CommandReference
command: Cache::SizeAwareMemoryCache
mode: perldoc
section: 
source: perldoc
---

## Quick Reference
- `my $cache = Cache::SizeAwareMemoryCache->new({ namespace => 'MyNS', default_expires_in => 600, max_size => 10000 });` — Create a cache with size limit.
- `$cache->set($key, $value);` — Store a value.
- `my $value = $cache->get($key);` — Retrieve a value.
- `$cache->limit_size(20000);` — Change maximum cache size.
- `$cache->clear();` — Remove all entries.
- `$cache->remove($key);` — Remove a specific entry.
- `$cache->size();` — Get current total size in bytes.
- `$cache->max_size();` — Get current maximum size.

## Name
Cache::SizeAwareMemoryCache -- extends Cache::MemoryCache with dynamic size limit

## Synopsis
perl
use Cache::SizeAwareMemoryCache;

my $cache = new Cache::SizeAwareMemoryCache(
    { 'namespace'          => 'MyNamespace',
      'default_expires_in' => 600,
      'max_size'           => 10000 }
);
## Options
Inherits options from [Cache::Cache](http://localhost/phpMan.php/perldoc/Cache%3A%3ACache/markdown) and [Cache::SizeAwareCache](http://localhost/phpMan.php/perldoc/Cache%3A%3ASizeAwareCache/markdown). Key additional option:
- `max_size` — maximum cache size in bytes.

## See Also
- [Cache::Cache](http://localhost/phpMan.php/perldoc/Cache%3A%3ACache/markdown)
- [Cache::SizeAwareCache](http://localhost/phpMan.php/perldoc/Cache%3A%3ASizeAwareCache/markdown)
- [Cache::MemoryCache](http://localhost/phpMan.php/perldoc/Cache%3A%3AMemoryCache/markdown)