Next:
Singleton::Session
Previous:
Singleton::DBI
 [Table of Contents]

Singleton::Memcache



NAME

Singleton::Memcache - A singleton wrapper around Danga's memcache.

SYNOPSIS

    #!/usr/bin/perl -w

    use Singleton::Memcache;
    use strict;

    # Get the cache handle.
    my $cache = Singleton::Memcache->instance();

    # Set a value in the cache, and retrieve it.
    $cache->set( "bob", "your uncle" );
    $cache->get( "bob" );

    # Finally delete the key.
    $cache->delete( "bob" );

DESCRIPTION

  This module implements a Singleton wrapper around Cache::Memcached,
 which allows global access to a running memcached instance.

  This singleton is a proxy object, which will attempt to create an
 object to forward requests to, and silently swallow requests if this
 creation fails.

  We will fail if:

   1.  The configuration file says we're disabled.
   2.  The <Cache::Memcached> Perl module isn't enabled, or otherwise
      fails to connect.

DISCUSSION

  For more discussion on the code, and why it is implemented in this
 manner you might be interested in the following node at Perlmonks:

   http://www.perlmonks.org/?node_id=507753

instance

  Gain access to the cache instance.  If the singleton object has been
 created return it.  Otherwise create a new instance.

new

  Constructor.  We connect to the cache, and store a reference to it
 internally.

  If the cache is disabled in the configuration file then we do nothing,
 similarly if the creation of the cache connection fails then we
 just quietly disable ourself.

disconnect

  Disconnect from the cache

get

  Get a key from the cache

set

  Set a key in the cache.  Note that we'll get a warning from Perl
 if we attempt to set an undefined value.

  We could catch it here, but we do not.

stats

  Return statistic information about the current server.

delete

  Delete a key from the cache.

AUTHOR

Steve Kemp

http://www.steve.org.uk/

LICENSE

Copyright (c) 2005-2007 by Steve Kemp. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The LICENSE file contains the full text of the license.


[Top] Generated by HTML::FromPod 0.49 on Fri Nov 21 03:03:57 2008