User:AnomieBOT/source/AnomieBOT/API/Cache/Memcached.pm/doc
Appearance
NAME
[edit]AnomieBOT::API::Cache::Memcached - AnomieBOT API cache using memcached
SYNOPSIS
[edit]use AnomieBOT::API::Cache; my $cache = AnomieBOT::API::Cache->create( 'Memcached', $optionString ); $cache->set( 'foo', 'bar' ); say $cache->get( 'foo' ); # Outputs "bar"
DESCRIPTION
[edit]AnomieBOT::API::Cache::Memcached
is an implementation of AnomieBOT::API::Cache using memcached for storage.
METHODS
[edit]In addition to the methods inherited from the base class, the following are available.
- AnomieBOT::API::Cache::Memcached->new( $optionString )
- Creates a new AnomieBOT::API::Cache::Memcached object. The option string is a semicolon-separated list of key-value pairs; if the value must contain a semicolon or backslash, escape it using a backslash.
- Recognized keys are:
- servers
- Comma-separated list of server addresses, and optional weights. Each server address is of the form "host:port" for network connections, or "/path/to/socket" for Unix domain socket connections. An integer weight may be specified by appending "!weight".
- namespace
- Prefix all keys with this string.
- connect_timeout
- Seconds to wait before considering a connection attempt has failed. Default 0.25 seconds.
- io_timeout
- Seconds to wait before considering a read or write attempt has failed. Default 1 second.
- max_size
- Maximum size of a data item, after compression. Larger data items will cause setting functions to return undef. Set 0 to disable. Default is 0.
- encrypt
- Encrypts the data before sending it to memcached, using the specified value as the encryption key. Default is empty, no encryption.
- user
- pass
- Username and password to send as an "authenticate" command, for sharp-memcached used in Tool Forge.
- verbose
- Output errors to stdout.
- $cache->socket_for_key( $key )
- Return the socket for the server used for a particular key. In a list context, also returns the internally munged key.
- $cache->all_sockets()
- Return sockets for all the servers.
- $cache->command( $sock, $cmd, $read_reply )
- Send a command to memcached. The command must include the terminal "\r\n", and may include binary data if applicable.
- Returns undef on error. On success, returns the (first) response line if
$read_reply
is true, or a true value otherwise. - $cache->read_response( $sock )
- Read a response line from memcached. The trailing "\r\n" is stripped.
- Returns the line on success, or undef on error.
- $cache->read_data( $sock, $length )
- Read binary response data from memcached.
$length
is the length in bytes to read, not including the trailing "\r\n". The trailing "\r\n" is stripped. - Returns the binary data on success, or undef on error.
COPYRIGHT
[edit]Copyright 2013 Anomie
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.