From ecde77e2a87cd87ce975c991b49edbaad3558a98 Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Thu, 29 Apr 2010 11:55:30 -0500 Subject: [PATCH] add perldoc --- lib/WebGUI/Cache/CHI.pm | 71 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/lib/WebGUI/Cache/CHI.pm b/lib/WebGUI/Cache/CHI.pm index 4bee8d0a6..6491afba1 100644 --- a/lib/WebGUI/Cache/CHI.pm +++ b/lib/WebGUI/Cache/CHI.pm @@ -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;