NAME
Maplat::Web::MemCache - Module for access to memcached
SYNOPSIS
This is a wrapper around Cache::Memcache (and similar) with a few addons.
DESCRIPTION
This module provides a web module that gives the caller an interface to the memcached service. Internally, it tries to use (in that order) Cache::Memcached::Fast, Cache::Memcached and Maplat::Helpers::Cache::Memcached and test if they actually can set and retrieve keys.
Configuration
<module>
<modname>memcache</modname>
<pm>MemCache</pm>
<options>
<service>127.0.0.1:11211</service>
<namespace>RBSMem</namespace>
<viewcommands>
<view>Adm Worker</view>
<view>Other Worker</view>
</viewcommands>
</options>
</module>
service is IP address and port of the memcached service
namespace if a single name assigned to all programs of the same project. Different projects accessing the same memcached server must use different namespaces, while all programs working on a common project must use the same namespace. this is so, because next to caching, memcached in the Maplat framework is also used for interprocess communication.
maxage is the maximum age in days the files are allowed to reside in the directory
limit denotes the limit of how many files to clean out in a single run. This option prevents the module of monopolizing harddisk IO.
Further, the main script must declare the variables $VERSION and $APPNAME, because some functionality of the wrapper needs those. This values are set in memcached and can be read out by the WebGUI as a central point of determing which versions and build of which program are running on the server. So, the variables
$main::APPNAME
$main::VERSION
must be accesible and hold reasonable values.
viewcommands is a list of workers that can work on the commandqueue table. This helps checking every worker for active commands and highlighting them in various other modules
refresh_lifetick()
Refreshed the lifetick variable for this application in 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.
Dependencies
This module is a basic module which does not depend on other web modules.
SEE ALSO
Maplat::Web
AUTHOR
Rene Schickbauer, <rene.schickbauer@magnapowertrain.com>
COPYRIGHT AND LICENSE
Copyright (C) 2009 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.