NAME

WWW::Suffit::Cache - Simple in-memory cache for WWW::Suffit web-servers

SYNOPSIS

use WWW::Suffit::Cache;

my $cache = WWW::Suffit::Cache->new(
    max_keys    => 100,
    expiration  => 60,
);

$cache->set(foo => 'bar');
$cache->set(foo => 'bar', 60);

my $foo = $cache->get('foo');

DESCRIPTION

Simple in-memory cache for WWW::Suffit web-servers with size limits and expirations

This module based on Mojo::Cache and Cache::Memory::Simple

ATTRIBUTES

This class implements the following attributes

max_keys

my $max = $cache->max_keys;
$cache  = $cache->max_keys(100);

Maximum number of cache keys. Setting the value to 0 or undef will disable caching by number of cache keys

expiration

my $exp = $cache->expiration;
$cache  = $cache->expiration(60);

This attribute performs sets or gets the default expiration seconds of live of cache record. Default is 0 -- disable

METHODS

This class inherits all methods from Mojo::Base and implements the following new ones

clean

$cache = $cache->clean;

Remove all data from cache

cleanup

$cache = $cache->cleanup;

Alias for "clean"

count

my $count = $cache->count;

Get actual number of cache records

del

$cache = $cache->del('foo');

Alias for "remove"

get

my $value = $cache->get('foo');

Get cached value

purge

$cache = $cache->purge;

Purge expired data

This module does not purge expired data automatically. You need to call this method if you need

remove

$cache = $cache->remove('foo');

Delete key from cache

rm

$cache = $cache->rm('foo');

Alias for "remove"

set

$cache = $cache->set(foo => 'bar');
$cache = $cache->set(foo => 'bar', 60);

Set cached value with/without expiration time

HISTORY

See Changes file

TO DO

See TODO file

SEE ALSO

Mojolicious, Mojo::Cache, Cache::Memory::Simple, Cache::Redis

AUTHOR

Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2024 D&D Corporation. All Rights Reserved

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See LICENSE file and https://dev.perl.org/licenses/