add perldoc

This commit is contained in:
Doug Bell 2010-04-29 11:55:30 -05:00
parent d073b83c9f
commit ecde77e2a8

View file

@ -4,11 +4,40 @@ use strict;
use base 'WebGUI::Cache';
use CHI;
=head1 NAME
WebGUI::Cache::CHI - CHI cache driver
=head1 DESCRIPTION
This is a WebGUI Cache driver to the CHI cache interface. This allows WebGUI
sites to use any CHI::Driver like FastMmap and Memcached
=head1 METHODS
=cut
#----------------------------------------------------------------------------
=head2 delete ( )
Delete the current key
=cut
sub delete {
my ( $self ) = @_;
return $self->{_chi}->remove( $self->{_key} );
}
#----------------------------------------------------------------------------
=head2 deleteChunk ( partialKey )
Delete multiple keys from the cache
=cut
sub deleteChunk {
my ( $self, $key ) = @_;
$key = $self->parseKey( $key );
@ -19,16 +48,41 @@ sub deleteChunk {
}
}
#----------------------------------------------------------------------------
=head2 flush ( )
Delete the entire cache namespace
=cut
sub flush {
my ( $self ) = @_;
$self->{_chi}->purge;
}
#----------------------------------------------------------------------------
=head2 get ( )
Get the data in the current key
=cut
sub get {
my ( $self ) = @_;
return $self->{_chi}->get( $self->{_key} );
}
#----------------------------------------------------------------------------
=head2 new ( session, key [, namespace] )
Create a new WebGUI::Cache object with the given key. The namespace defaults
to the current site's configuration file name
=cut
sub new {
my ( $class, $session, $key, $namespace ) = @_;
my $namespace ||= $session->config->getFilename;
@ -63,6 +117,15 @@ sub new {
return bless { _session => $session, _key => $key, _chi => $chi }, $class;
}
#----------------------------------------------------------------------------
=head2 set ( content [, ttl ] )
Set the content to the current key. ttl is the number of seconds the cache
should live.
=cut
sub set {
my ( $self, $content, $ttl ) = @_;
$ttl ||= 60;
@ -70,6 +133,14 @@ sub set {
return;
}
#----------------------------------------------------------------------------
=head2 stats ( )
Get the size of the cache
=cut
sub stats {
my ( $self ) = @_;
return $self->{_chi}->get_size;