# Io Reference

Databases / Memcached / Memcached

|  | memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. Memcached is an Io client library for memcached, based on C libmemcached.
|  | add(key, value[, expiration]) Asks memcached to store the value identified by the key, but only if the server *doesn't* already hold data for this key. Returns true on success, false in case of a collision. Otherwise raises an exception. addServer(address) Adds a memcached server. address is a "host:port" string, e.g., "127.0.0.1:11211" Returns self. append(key, value) Asks memcached to add this value to an existing key after existing value. Returns true on success, otherwise raises an exception. value should be a Sequence. Supported by memcached 1.2.4+ at(key, optionalDefaultValue) Asks memcached to retrieve data corresponding to the key. Returns nil if the data is not there (or if the data *is* nil). atIfAbsentPut(key, value[, expiration]) If a value is present at the specified key, its value is returned. Otherwise, inserts the new value and returns it. atPut(key, value[, expiration]) Asks memcached to store the value identified by the key. Same as Memcached set, but returns self. decr([offset]) Asks memcached to decrement data for some item in place. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Default offset is 1. Returns the new value. delete(key[, time]) Asks memcached to delete an item with the given key. time is the amount of time in seconds (or Unix time until which) the client wishes the server to refuse "add" and "replace" commands with this key. Returns true on success, false if there is no item with the given key. Otherwise raises an exception. flushAll([expiration]) Asks memcached to invalidate all existing items immediately (by default) or after the expiration specified. Always returns true. get(key) Asks memcached to retrieve data corresponding to the key. Raises "NOT FOUND" if the data is not there. getMulti(keys) Asks memcached to retrieve data corresponding to the list of keys. Returns a Map with the results. If some of the keys appearing in a retrieval request are not sent back by the server in the item list this means that the server does not hold items with such keys incr([offset]) Asks memcached to increment data for some item in place. The data for the item is treated as decimal representation of a 64-bit unsigned integer. If the current data value does not conform to such a representation, the commands behave as if the value were 0. Default offset is 1. Returns the new value. prepend(key, value) Asks memcached to add this value to an existing key before existing value. Returns true on success, otherwise raises an exception. value should be a Sequence. Supported by memcached 1.2.4+ removeAt(key) Asks memcached to remove value with a given key. Returns self. replace(key, value[, expiration]) Asks memcached to store the value identified by the key, but only if the server *does* already hold data for this key. Returns true on success, false if there is already data for this key. Otherwise raises an exception. set(key, value[, expiration]) Asks memcached to store the value identified by the key. Returns true on success, otherwise raises an exception. stats Returns a Map with servers' statistics. Keys are server addresses, values are maps with actual stats. with(servers) Returns a new instance of Memcached. Accepts a Sequence or a List of server addresses.