NAME

Sledge::Cache - Abstract base class for sledge's cache class

SYNOPSIS

package Sledge::Cache::Foo;
use base 'Sledge::Cache';
sub _init {
    my ($self, $page) = @_;
    # initialize
}
sub _get {
    my ($self, $key) = @_;
    # get value
}
sub _set {
    my ($self, $key, $val, $exptime) = @_;
    # set value
}
sub _remove {
    my ($self, $key) = @_;
    # remove value
}

package Your::Pages;
use Sledge::Cache::Foo;
sub create_cache { Sledge::Cache::Foo->new(shift) }
sub dispatch_shokotan {
    my $self = shift;
    my $shokotan = $self->cache->get_callback(
        shokotan => sub { Your::Data->retrieve('shokotan') },
    );
    $self->tmpl->param(shokotan => $shokotan);
}

DESCRIPTION

Sledge::Cache is abstract base class for sledge's cache class.

METHODS

new

Returns a new Sledge::Cache object.

get_callback

my $shokotan = $self->cache->get_callback(
    shokotan => sub { Your::Data->retrieve('shokotan') }
);

This checks if a Shokotan can be found to match the information passed, and if not store it.

param

my $shokotan = $self->cache->param('shokotan');
$self->cache->param('shokotan' => $shokotan);

Get or set the cache(likes Sledge::Pages::Base, Sledge::Template, etc.).

remove

$self->cache->remove('shokotan');

Deletes a key.

ABSTRACT METHODS

_init(PAGES)

_get(KEY)

_set(KEY, VALUE, EXPTIME)

_remove(KEY)

You'll must override in your child class.

AUTHOR

MATSUNO Tokuhiro <tokuhiro at mobilefactory.jp>

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

SEE ALSO

Sledge::Plugin::Cache, Bundle::Sledge