Rene Schickbauer

NAME

Maplat::Web::MemCachePg - PostgreSQL-backed memcache module

SYNOPSIS

This is an API compatible implementation of Maplat::Web::MemCache. Internally, it uses that module in combination with the PostgreSQL webmodule.

DESCRIPTION

You can use this module as a drop-in replacement of Maplat::Web::MemCache (that module still needs to be configured, though, because we used it here to speed up data retrieval). In addition of using the real memcache daemon, we also save the data to the configured database, e.g. implement a permanent storage engine on top of memcached.

And, yes, i know that there is a general Berkeley DB backed memcached available. This means you need still another database and it might not be available on all operating systems. If you choose to use the real db backed memcached, just use Maplat::Web::MemCache. This one uses the configured PostgreSQL module to do its stuff, so it should work everywhere where Maplat and PostgreSQL are available.

Configuration

        <module>
                <modname>memcachepg</modname>
                <pm>MemCachePg</pm>
                <options>
                  <memcache>memcache</memcache>
                  <db>maindb</db>
                </options>
        </module>

WARNING

If you want to store data permanent (even within a single program run), you should use Maplat::Web::MemCachePg, which is using Maplat::Web::MemCache, but also uses the PostgreSQL module as a permanent backing store.

The memcache daemon itself is very fast, but is basically a cache; e.g. if more data comes in that it can hold, the oldest data is silently discarded. Therefore, using a backing store for things like Login-data, shopping cart contents and other things you want to permanently store, use a real backing store. You dont want to loose some session information because more users logged on than memcached was set to handle.

A few Maplat::Web:: modules implement their own caching strategy, like the UserSettings module. For these, you should *not* use Maplat::Web::MemCachePg but Maplat::Web::MemCache, otherwise you negate some of the performance due to overhead (double store).

refresh_lifetick

Refresh the lifetick variable for this application in (real) memcached.

disable_lifetick

Disable the lifetick variable for this application in (real) memcached.

set

Save data in memcached.

Takes two arguments, a key name and a reference to the data to be stored in memcached. Returns a boolean to indicate success or failure.

get

Read data from memcached. Takes one argument, the key name, returns a reference to the data from memcached or undef.

delete

Delete a key from memcached. Takes one argument, the key name, returns a boolean indicating success or failure.

set_activecommand

Sets the command currently processed by this application (or 0 to indicate no active command). Takes one argument, the id of the currently active command. Returns a boolean indicating success or failure.

get_activecommands

Returns a hash with all currently active commands in all (configured) workers, webguis and other apps.

sanitize_key

Internal function to sanitize (clean up and re-encode) the memcached key string. Memcached has some limitations how the keys can be named, this functions is used on every access to memcached to make sure the keys adhere to this restrictions.

Dependencies

This module depends on Maplat::Web::MemCache and Maplat::Web::PostgresDB

AKA

Also Known As "database backed storage engine for general data junk".

If you are using MemCache on a production system for data you *must* be able to retrieve again, you really should be thinking of using THIS module instead of Maplat::Web::MemCache, unless you implement your own permanent storage solution.

SEE ALSO

Maplat::Web

AUTHOR

Rene Schickbauer, <rene.schickbauer@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2008-2011 by Rene Schickbauer

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.