The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Cache::Memcached::Indexable - A key indexable Cache::Memcached wrapper

SYNOPSIS

 use Cache::Memcached::Indexable;
 
 $memd = new Cache::Memcached::Indexable {
     'servers' => [ "10.0.0.15:11211", "10.0.0.15:11212",
                    "10.0.0.17:11211", [ "10.0.0.17:11211", 3 ] ],
     'debug' => 0,
     'compress_threshold' => 10_000,
 };
 $memd->set_servers($array_ref);
 $memd->set_compress_threshold(10_000);
 $memd->enable_compress(0);
 
 $memd->set("my_key", "Some value");
 $memd->set("object_key", { 'complex' => [ "object", 2, 4 ]});
 
 $val = $memd->get("my_key");
 $val = $memd->get("object_key");
 if ($val) { print $val->{'complex'}->[2]; }
 
 $memd->incr("key");
 $memd->decr("key");
 $memd->incr("key", 2);
 
 @all_keys = $memd->keys;

DESCRIPTION

THIS IS ALPHA SOFTWARE

Cache::Memcached::Indexable is a key indexable memcached interface. It is a simple wrapper class of Cache::Memcached. Usually, we can't get any key information of stored data with using memcached. This module provides keys() method (likes CORE::keys()) for getting all of stored key information.

In fact, this module uses only a few patterns of knowable key, and it stores the key with the value of large hash-ref. It controls the large hash-ref when you call set, get or delete methods.

It was implantated some functions of Cache::Memcached. But the implanted functions are only documented functions. Note that some undocumented functions weren't implanted to this module.

CONSTRUCTOR

new

Takes one parameter, a hashref of options. Almost same as Cache::Memcached's constructor. But it has some additional parameter.

  • logic

    The parameter of logic is the name of your chosen logic class or the entity of the logic class instance.

     $memd = Cache::Memcached::Indexable->new({
         logic      => 'Cache::Memcached::Indexable::Logic::DigestSHA1',
         logic_args => { set_max_power => 0xFF },
         %memcached_args,
     })

    and the following code is same as above:

     use Cache::Memcached::Indexable::Logic::DigestSHA1;
    
     $logic = Cache::Memcached::Indexable::Logic::DigestSHA1->new({
         set_max_power => 0xFF,
     });
     
     $memd = Cache::Memcached::Indexable->new({
         logic => $logic,
         %memcached_args,
     });
  • logic_args

    The arguments of your specified logic class (see above.)

  • memd

    You may specify your favorite memcached interface class. But it must have Cache::Memcached compatibility (e.g. Cache::Memcached::XS).

METHODS

keys()

You can get all of stored keys with calling this method.

And the usage of following methods. See Cache::Memcached document.

set_servers
set_debug
set_readonly
set_norehash
set_compress_threshold
enable_compress
get
get_multi
set
add
replace
delete
incr
decr
stats
disconnect_all
flush_all

WARRANTY

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

AUTHOR

Koichi Taniguchi <taniguchi@livedoor.jp>

LICENSE

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

SEE ALSO

Cache::Memcached, Cache::Memcached::Indexable::Logic, Cache::Memcached::Indexable::Logic::Default