NAME

Memcached::libmemcached - Thin fast interface to the libmemcached client API

VERSION

Version 0.01

SYNOPSIS

use Memcached::libmemcached;

EXPORTS

All the public functions in libmemcached are available for import.

All the public constants and enums in libmemcached are available for import.

Exporter tags are defined for each enum. This allows you to import groups of constants easily. For example, to import all the contants for memcached_behavior_set() and memcached_behavior_get(), you can use:

use Memcached::libmemcached qw(:memcached_behavior).

FUNCTIONS

Conventions

Memcached::libmemcached is a very thin, highly efficient, wrapper around the libmemcached library. The libmemcached library documentation (which is bundled with Memcached::libmemcached) serves as the primary reference for the functionality.

This documentation aims to provide just a summary of the functions, along with any issues specific to this perl interface.

Terminology

The term "memcache" is used to refer to the memcached_st structure at the heart of the libmemcached library. The examples use $memc to represent this structure.

Arguments

There are no length arguments. Wherever the libmemcached documentation shows a length argument (input or output) the corresponding argument doesn't exist in the Perl API.

For pointer arguments, undef is mapped to null on input and null is mapped to undef on output.

Return

Most of the methods return an integer status value. This is shown as memcached_return in the libmemcached documentation.

TODO: make a dual-var with integer and string parts (via typemap)

Functions For Managing Memcaches

memcached_create

my $memc = memcached_create();

Creates and returns a 'memcache' that represents the state of communication with a set of memcached servers. See Memcached::libmemcached::memcached_create.

memcached_clone

my $memc = memcached_clone(undef, undef);

XXX Not currently recommended for use. See Memcached::libmemcached::memcached_create.

memcached_free

memcached_free($memc);

Frees the memory associated with $memc. Your application will leak memory unless you call this. After calling it $memc must not be used. See Memcached::libmemcached::memcached_create.

memcached_server_push

memcached_server_push($memc, $server_list_object);

Adds a list of servers to the libmemcached object. See Memcached::libmemcached::memcached_servers.

memcached_server_count

$server_count= memcached_server_count($memc);

Returns a count of the number of servers associated with $memc. See Memcached::libmemcached::memcached_servers.

memcached_server_list

$server_list= memcached_server_list($memc);

Returns the server list structure associated with $memc. XXX Not currently recommended for use. See Memcached::libmemcached::memcached_servers.

memcached_server_add

memcached_server_add($memc, $hostname, $port);

Adds details of a single memcached server (accessed via TCP/IP) to $memc. See Memcached::libmemcached::memcached_servers.

memcached_server_add_unix_socket

memcached_server_add_unix_socket($memc, $socket_path);

Adds details of a single memcached server (accessed via a UNIX domain socket) to $memc. See Memcached::libmemcached::memcached_servers.

memcached_behavior_set

memcached_behavior_set($memc, $option_key, $option_value);

Changes the value of a particular option. See Memcached::libmemcached::memcached_behavior.

memcached_behavior_get

memcached_behavior_get($memc, $option_key);

Get the value of a particular option. See Memcached::libmemcached::memcached_behavior.

memcached_verbosity

memcached_verbosity($memc, $verbosity)

Modifies the "verbosity" of the associated memcached servers. See Memcached::libmemcached::memcached_verbosity.

memcached_flush

memcached_flush($memc, $expiration);

Wipe clean the contents of associated memcached servers. See Memcached::libmemcached::memcached_flush.

memcached_quit

memcached_quit($memc);

Disconnect from all currently connected servers and reset state. Not normally called explicitly. See Memcached::libmemcached::memcached_quit.

Functions for Setting Values in memcached

See Memcached::libmemcached::memcached_set.

memcached_set

memcached_set($memc, $key, $value);
memcached_set($memc, $key, $value, $expiration, $flags);

Set $value as the value of $key. $expiration and $flags are both optional and default to 0.

memcached_append

memcached_append($memc, $key, $value);
memcached_append($memc, $key, $value, $expiration, $flags);

Append $value to the value of $key. $key must already exist. $expiration and $flags are both optional and default to 0.

memcached_prepend

memcached_prepend($memc, $key, $value)
memcached_prepend($memc, $key, $value, $expiration, $flags)

Prepend $value to the value of $key. $key must already exist. $expiration and $flags are both optional and default to 0.

Functions for Fetching Values from memcached

See Memcached::libmemcached::memcached_get.

memcached_get

$value = memcached_get($memc, $key, $flags, $rc);
$value = memcached_get($memc, $key);

Get and return the value of $key. Returns undef on error.

Also updates $flags to the value of the flags stored with $value, and updates $rc with the return code.

Functions for Incrementing and Decrementing Values from memcached

memcached_increment

$return = memcached_increment( $key, $offset, $new_value_out );

Increments the value associated with $key by $offset and returns the new value in $new_value_out. See also Memcached::libmemcached::memcached_auto.

memcached_decrement

memcached_decrement( $key, $offset, $new_value_out );

Decrements the value associated with $key by $offset and returns the new value in $new_value_out. See also Memcached::libmemcached::memcached_auto.

Functions for Managing Results from memcached

XXX http://hg.tangent.org/libmemcached/file/4001ba159d62/docs/memcached_result_st.pod

Functions for Deleting Values from memcached

See Memcached::libmemcached::memcached_delete.

memcached_delete

memcached_delete($memc, $key);
memcached_delete($memc, $key, $expiration);

Delete $key. If $expiration is greater than zero then the key is deleted by memcached after that many seconds.

Functions for Accessing Statistics from memcached

XXX http://hg.tangent.org/libmemcached/file/4001ba159d62/docs/memcached_stats.pod

Miscellaneous Functions

memcached_strerror

$string = memcached_strerror($memc, $return_code)

memcached_strerror() takes a memcached_return value and returns a string describing the error. The string should be treated as read-only (it may be so in future versions). See also Memcached::libmemcached::memcached_strerror.

AUTHOR

Tim Bunce, <Tim.Bunce@pobox.com>

BUGS

Please report any bugs or feature requests to bug-memcached-libmemcached@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Memcached-libmemcached. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2007 Tim Bunce, All Rights Reserved.

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