powerman / perl-Cache-Sliding

Perl module: Cache::Sliding - Cache using sliding time-based expiration strategy

Home Page:https://metacpan.org/release/Cache-Sliding

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Coverage Status

NAME

Cache::Sliding - Cache using sliding time-based expiration strategy

VERSION

This document describes Cache::Sliding version v2.0.1

SYNOPSIS

use Cache::Sliding;

$cache = Cache::Sliding->new(10*60);

$cache->set($key, $value);
$value = $cache->get($key);
$cache->del($key);

DESCRIPTION

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.

INTERFACE

new

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

set

$cache->set( $key, $value );

Add new item into cache. Will replace existing item for that $key, if any.

get

$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 ()

del

$cache->del( $key );

Remove item for $key from cache, if any. Return nothing.

SUPPORT

Bugs / Feature Requests

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.

Source Code

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

Resources

AUTHOR

Alex Efros <powerman@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2009- by Alex Efros <powerman@cpan.org>.

This is free software, licensed under:

The MIT (X11) License

About

Perl module: Cache::Sliding - Cache using sliding time-based expiration strategy

https://metacpan.org/release/Cache-Sliding

License:Other


Languages

Language:Perl 93.7%Language:Perl 6 6.3%