| 1 |
=head1 NAME |
| 2 |
|
| 3 |
Tie::Cache::LRU - A Least-Recently Used cache |
| 4 |
|
| 5 |
|
| 6 |
=head1 SYNOPSIS |
| 7 |
|
| 8 |
tie %cache, 'Tie::Cache::LRU', 500; |
| 9 |
tie %cache, 'Tie::Cache::LRU', '400k'; #UNIMPLEMENTED |
| 10 |
|
| 11 |
# Use like a normal hash. |
| 12 |
|
| 13 |
$cache_obj = tied %cache; |
| 14 |
$current_size = $cache_obj->curr_size; |
| 15 |
|
| 16 |
$max_size = $cache_obj->max_size; |
| 17 |
$cache_obj->max_size($new_size); |
| 18 |
|
| 19 |
|
| 20 |
=head1 DESCRIPTION |
| 21 |
|
| 22 |
This is an implementation of a least-recently used (LRU) cache keeping |
| 23 |
the cache in RAM. |
| 24 |
|
| 25 |
A LRU cache is similar to the kind of cache used by a web browser. |
| 26 |
New items are placed into the top of the cache. When the cache grows |
| 27 |
past its size limit, it throws away items off the bottom. The trick |
| 28 |
is that whenever an item is -accessed-, it is pulled back to the top. |
| 29 |
The end result of all this is that items which are frequently accessed |
| 30 |
tend to stay in the cache. |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
=head1 AUTHOR |
| 35 |
|
| 36 |
Michael G Schwern <[email protected]> for Arena Networks |
| 37 |
|
| 38 |
|
| 39 |
WHAT IS THIS? |
| 40 |
|
| 41 |
This is Tie::Cache::LRU, a perl module. Please see the README that comes with |
| 42 |
this distribution. |
| 43 |
|
| 44 |
HOW DO I INSTALL IT? |
| 45 |
|
| 46 |
To install this module, cd to the directory that contains this README |
| 47 |
file and type the following: |
| 48 |
|
| 49 |
perl Makefile.PL |
| 50 |
make |
| 51 |
make test |
| 52 |
make install |
| 53 |
|
| 54 |
To install this module into a specific directory, do: |
| 55 |
perl Makefile.PL PREFIX=/name/of/the/directory |
| 56 |
...the rest is the same... |
| 57 |
|
| 58 |
Please also read the perlmodinstall man page, if available. |
| 59 |
|
| 60 |
WHAT MODULES DO I NEED? |
| 61 |
|
| 62 |
Carp::Assert |
| 63 |
enum |
| 64 |
Class::Virtual |
| 65 |
Class::Data::Inheritable |
| 66 |
Test::More |