Cache::Sliding - Cache using sliding time-based expiration strategy
This document describes Cache::Sliding version v2.0.1
use Cache::Sliding; $cache = Cache::Sliding->new(10*60); $cache->set($key, $value); $value = $cache->get($key); $cache->del($key);
Implement caching object using sliding time-based expiration strategy (data in the cache is invalidated by specifying the amount of time the item is allowed to be idle in the cache after last access time).
Use EV::timer, so this module only useful in EV-based applications, because cache expiration will work only while you inside EV::loop.
$cache = Cache::Sliding->new( $expire_after );
Create and return new cache object. Elements in this cache will expire between $expire_after seconds and 2*$expire_after seconds.
$cache->set( $key, $value );
Add new item into cache. Will replace existing item for that $key, if any.
$value = $cache->get( $key );
Return value of cached item for $key. If there no cached item for that $key return nothing.
For example, if you may keep undefined values in cache and still wanna be able to check is item was found in cache:
$cache->set( 'item 1', undef ); $val = $cache->get( 'item 1' ); # $val is undef @val = $cache->get( 'item 1' ); # @val is (undef) $val = $cache->get( 'nosuch' ); # $val is undef @val = $cache->get( 'nosuch' ); # @val is ()
$cache->del( $key );
Remove item for $key from cache, if any. Return nothing.
Please report any bugs or feature requests through the issue tracker at https://github.com/powerman/perl-Cache-Sliding/issues. You will be notified automatically of any progress on your issue.
This is open source software. The code repository is available for public review and contribution under the terms of the license. Feel free to fork the repository and submit pull requests.
https://github.com/powerman/perl-Cache-Sliding
git clone https://github.com/powerman/perl-Cache-Sliding.git
MetaCPAN Search
https://metacpan.org/search?q=Cache-Sliding
CPAN Ratings
http://cpanratings.perl.org/dist/Cache-Sliding
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Cache-Sliding
CPAN Testers Matrix
http://matrix.cpantesters.org/?dist=Cache-Sliding
CPANTS: A CPAN Testing Service (Kwalitee)
http://cpants.cpanauthors.org/dist/Cache-Sliding
Alex Efros <powerman@cpan.org>
This software is Copyright (c) 2009- by Alex Efros <powerman@cpan.org>.
This is free software, licensed under:
The MIT (X11) License
To install Cache::Sliding, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Cache::Sliding
CPAN shell
perl -MCPAN -e shell install Cache::Sliding
For more information on module installation, please visit the detailed CPAN module installation guide.