Apache::Session::Store::libmemcached - Memcached::libmemcached
Version 0.01
use Apache::Session::libmemcache tie %hash, 'Apache::Session::libmemcache', $id, { servers => ['1.2.3.4:2100', '4.3.2.1:2100'], expiration => 300, # In seconds log_errors => 1, } # to enable a simple load balancing feature # and/or fail over tie %hash, 'Apache::Session::libmemcache', $id, { load_balance => [ ['1.2.3.4:2100', '4.3.2.1:2100'], ['1.1.1.1:2100', '2.2.2.2:2100'], ], failover => 1, expiration => 300, # In seconds log_errors => 1, };
Apache::Session::Store::libmemcached fulfills the storage interface of Apache::Session. Session data is stored memcached using Memcached::libmemcached
Array reference containing strings with the format server:port. You can include multiple servers.
Optional parameter that sets the xpiration time of the session. This is takes advantage of a memcached feature that allows to set keys with expiration time. 0, undef sets no expiration time.
If this parameter is set to 1, error messages will be outputed to STDERR if a memcached operation fails.
You can use this paramater instead of servers. It takes multiple server pools. Each pool is represented by an array reference containing strings with the format server:port.
When this parameter is used read operations will be load balanced between the available pools.
The current balancing method is pretty straightforward. It uses the first character of the session identifier to select the pool. On average and given random session indentifiers memcache operation will be evenly distributed amongst the available pools.
When failover is enabled, write operations take place in all the available pools. Read operations are still load balanced. However, in the event of a read operation fail, the other available pools will be used.
Insert a session id into memcached. It will die if the key already exists.
Replace a session id into memcached.
Retrieve the content of a session id
Remove a session id from mecached
Private method that takes care of connecting to the memcache servers.
Private method to read sessions.
If load balance is enabled it will read from the right cache.
If it fails and failover is enabled, it will try to read from other pools.
Private method to select a pool to read from.
We just use 'first session id character' mod $numberOfPools to select a pool.
Note that we return the first available pool if load balance is not enabled or if there is only one pool.
Private method to return which pools must be updated.
If failover is not enabled only one pool is returned. Otherwise the designated pool will be returned.
Private method to read from a given pool.
If read fails it will log the error in case logging is enabled.
Private method to set a key-value entry in all the configured pools.
Private method to log error messages
You can find documentation for this module with the perldoc command.
perldoc Apache::Session::libmemcached
Javier Uruen Val <javi.uruen@gmail.com>
<javi.uruen@gmail.com>
Copyright (C) 2010 Venda Ltd
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install Apache::Session::libmemcached, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Apache::Session::libmemcached
CPAN shell
perl -MCPAN -e shell install Apache::Session::libmemcached
For more information on module installation, please visit the detailed CPAN module installation guide.