memcached

Provides work with memcached.

Usage:

List of memcached methods

Name Arguments Returns Description
new Memcached Memcached constructor does basically nothing. It just adds "this.close()" method to global GC
reset args.This() Re-initializes the underlying memcached connection and clears all state
* previously matained. Note that this does not effect the actual memcached
* servers but does clear the list of servers used by this connection.
setPrefixKey String args.This() Sets the prefix key. The prefix key will be used to create a domain for your keys. The value specified here will be prefixed to each of your keys. The value can not be greater then MEMCACHED_PREFIX_KEY_MAX_SIZE - 1 and will reduce MEMCACHED_MAX_KEY by the value of your key. The prefix key is only applied to the primary key, not the master key.
getPrefixKey String Returns the current prefix key used.
clearPrefixKey args.This() Clears the prefix key so that no prefix key will be used.
addServerWithWeight String, Int, Int args.This() Adds a server by host, port and weight to the list of servers that will handle requests.
flush Int args.This() Wipes the contents of memcached servers. It will either do this immediately or expire the content based on the expiration time passed to the method. An expiration time of 0 causes an immediate flush. The operation is not atomic to multiple servers, just atomic to a single server. That is, it will flush the servers in the order that they were added.
set String, String, Int, Int args.This() Writes an object to the server. If an object already exists it will overwrite what is in the server. If the object does not exist it will be written.
replace String, String, Int, Int args.This() Replaces an object on the server. If the object is not found on the server an error occurs.
add String, String, Int, Int args.This() Adds an object on the server. If the object is found on the server an error occurs, otherwise the value is stored.
remove String, Int args.This() Deletes a particular key. Expiration works by placing the item into a delete queue, which means that it won't possible to retrieve it by the "get" command, but "add" and "replace" command with this key will also fail (the "set" command will succeed, however). After the time passes, the item is finally deleted from server memory.
Please note the the Danga memcached server removed support for expiration in the 1.4 version.
get String Array Fetches an individual value from the server by key. Returns undefined if no value was set for the key. Note that there is currently no way of getting the CAS value of the result with get in libmemcached so we do not return it here. If you need the CAS value you can use mget.
cas String, String, Int, Int, Array args.This() Check and set operation. Like set, but will only update the value, flags, and expiration if the CAS value passed in matches that which is still associated with the key. This can be used to ensure that no other clients have modified a value since you read it with mget.
mget Array Array Fetches multiple keys at once by key. Returns an array of arrays where each nested array is a [key, value, flags, cas] tuple. If a given key was found then there will be a tuple for it, otherwise no tuple will exist for the key.
behaviorSet Int, Int args.This() Changes the value of a particular option of the client. It takes both a flag (listed below) and a value. For simple on or off options you just need to pass in a value of 1. Calls to behaviorSet will flush and reset all connections.
behaviorGet Int Int Gets current behavior.