object
memcached
Portable Memcached client implementing the text (ASCII) protocol. Uses the sockets library for TCP communication.
logtalk_load(memcached(loader))static, context_switching_calls
Supported backends: ECLiPSe, GNU Prolog, SICStus Prolog, SWI-Prolog, and Trealla Prolog (same as the sockets library).
Protocol version: Implements the Memcached text (ASCII) protocol as documented in the official protocol.txt specification.
Connection: The default Memcached port is 11211. Connections are represented as opaque handles that should be passed to all other predicates.
Keys: Keys are atoms up to 250 characters. They must not include control characters or whitespace.
Flags: Flags are 32-bit unsigned integers stored alongside the data, opaque to the server.
Expiration: Expiration time in seconds. 0 means never expire. Values over 30 days (2592000) are treated as Unix timestamps.
Storage commands: Supports set, add, replace, append, prepend, and cas (check-and-set).
Retrieval commands: Supports get, gets (with CAS token), gat, and gats (get-and-touch).
Other commands: Supports delete, incr/decr, touch, flush_all, version, stats, and quit.
Public predicates
connect/3
Connects to a Memcached server at the given host and port. Returns a connection handle for subsequent operations.
staticconnect(Host,Port,Connection)connect(+atom,+integer,--compound) - one_or_errormemcached_error(connection_failed)connect/2
Connects to a Memcached server at the given host on the default port (11211). Returns a connection handle for subsequent operations.
staticconnect(Host,Connection)connect(+atom,--compound) - one_or_errormemcached_error(connection_failed)disconnect/1
Disconnects from the Memcached server. Sends a quit command before closing.
staticdisconnect(Connection)disconnect(+compound) - oneset/5
Stores the data unconditionally. Overwrites any existing data for the key.
staticset(Connection,Key,Value,Flags,ExpTime)set(+compound,+atom,+atom,+integer,+integer) - one_or_errormemcached_error(not_stored)memcached_error(Error)set/3
Stores the data unconditionally with default flags (0) and no expiration (0).
staticset(Connection,Key,Value)set(+compound,+atom,+atom) - one_or_errormemcached_error(not_stored)memcached_error(Error)add/5
Stores the data only if the key does not already exist.
staticadd(Connection,Key,Value,Flags,ExpTime)add(+compound,+atom,+atom,+integer,+integer) - one_or_errormemcached_error(not_stored)memcached_error(Error)replace/5
Stores the data only if the key already exists.
staticreplace(Connection,Key,Value,Flags,ExpTime)replace(+compound,+atom,+atom,+integer,+integer) - one_or_errormemcached_error(not_stored)memcached_error(Error)append/3
Appends the data to the end of an existing item’s data.
staticappend(Connection,Key,Value)append(+compound,+atom,+atom) - one_or_errormemcached_error(not_stored)memcached_error(Error)prepend/3
Prepends the data to the beginning of an existing item’s data.
staticprepend(Connection,Key,Value)prepend(+compound,+atom,+atom) - one_or_errormemcached_error(not_stored)memcached_error(Error)cas/6
Stores the data only if no one else has updated it since the given CAS unique value was obtained (via gets/3).
staticcas(Connection,Key,Value,Flags,ExpTime,CasUnique)cas(+compound,+atom,+atom,+integer,+integer,+integer) - one_or_errormemcached_error(exists)memcached_error(not_found)memcached_error(Error)get/3
Retrieves the value associated with the key. Fails if the key is not found.
staticget(Connection,Key,Value)get(+compound,+atom,-atom) - zero_or_one_or_errorget/4
Retrieves the value and flags associated with the key. Fails if the key is not found.
staticget(Connection,Key,Value,Flags)get(+compound,+atom,-atom,-integer) - zero_or_one_or_errorgets/4
Retrieves the value and CAS unique token for the key. Fails if the key is not found. The CAS value is used with the cas/6 predicate.
staticgets(Connection,Key,Value,CasUnique)gets(+compound,+atom,-atom,-integer) - zero_or_one_or_errorgets/5
Retrieves the value, flags, and CAS unique token for the key. Fails if the key is not found.
staticgets(Connection,Key,Value,Flags,CasUnique)gets(+compound,+atom,-atom,-integer,-integer) - zero_or_one_or_errormget/3
Retrieves multiple keys at once. Returns a list of item(Key, Value, Flags) terms for found keys.
staticmget(Connection,Keys,Items)mget(+compound,+list(atom),-list(compound)) - one_or_errordelete/2
Deletes the item with the given key. Fails if the key is not found.
staticdelete(Connection,Key)delete(+compound,+atom) - zero_or_one_or_errorincr/4
Increments the numeric value of the given key by the specified amount. Returns the new value. The item must already exist and contain a decimal representation of a 64-bit unsigned integer. Fails if the key is not found.
staticincr(Connection,Key,Amount,NewValue)incr(+compound,+atom,+integer,-integer) - zero_or_one_or_errordecr/4
Decrements the numeric value of the given key by the specified amount. Returns the new value. Underflow is caught: decrementing below 0 yields 0. Fails if the key is not found.
staticdecr(Connection,Key,Amount,NewValue)decr(+compound,+atom,+integer,-integer) - zero_or_one_or_errortouch/3
Updates the expiration time of the given key without fetching the data. Fails if the key is not found.
statictouch(Connection,Key,ExpTime)touch(+compound,+atom,+integer) - zero_or_one_or_errorgat/4
Gets the value of the key and updates its expiration time. Fails if the key is not found.
staticgat(Connection,Key,ExpTime,Value)gat(+compound,+atom,+integer,-atom) - zero_or_one_or_errorgats/5
Gets the value and CAS unique token of the key and updates its expiration time. Fails if the key is not found.
staticgats(Connection,Key,ExpTime,Value,CasUnique)gats(+compound,+atom,+integer,-atom,-integer) - zero_or_one_or_errorflush_all/1
Invalidates all existing items immediately.
staticflush_all(Connection)flush_all(+compound) - one_or_errorflush_all/2
Invalidates all existing items after the specified number of seconds.
staticflush_all(Connection,Delay)flush_all(+compound,+integer) - one_or_errorversion/2
Returns the version string of the Memcached server.
staticversion(Connection,Version)version(+compound,-atom) - one_or_errorstats/2
Returns general-purpose statistics as a list of stat(Name, Value) terms.
staticstats(Connection,Stats)stats(+compound,-list(compound)) - one_or_errorstats/3
Returns statistics for the given argument (e.g. items, slabs, sizes) as a list of stat(Name, Value) terms.
staticstats(Connection,Argument,Stats)stats(+compound,+atom,-list(compound)) - one_or_errorProtected predicates
(no local declarations; see entity ancestors if any)
Private predicates
(no local declarations; see entity ancestors if any)
Operators
(none)