Common Lisp Package: CL-MEMCACHED

README:

FUNCTION

Public

MC-DECR (KEY &KEY (MEMCACHE *MEMCACHE*) (VALUE 1) (USE-POOL *USE-POOL*))

Implements the DECR command. Decrements the value of a key. Please read memcached documentation for more information

MC-DEL (KEY &KEY (MEMCACHE *MEMCACHE*) ((TIME TIME) 0) (USE-POOL *USE-POOL*))

Deletes a particular 'key' and it's associated data from the memcached server

MC-GET (KEYS-LIST &KEY (MEMCACHE *MEMCACHE*) (USE-POOL *USE-POOL*) (IS-STRING NIL))

Retrive value for key from memcached server. keys-list => is a list of the keys, seperated by whitespace, by which data is stored in memcached memcache => The instance of class memcache which represnts the memcached we want to use. Returns a list of lists where each list has two elements key and value key is of type SIMPLE-STRING value is of type (UNSIGNED-BYTE 8)

MC-GET+ (KEY-OR-LIST-OF-KEYS &KEY (MEMCACHE *MEMCACHE*) (USE-POOL *USE-POOL*))

To be used for non-binary data only. If one key is given returns the response in string format

MC-INCR (KEY &KEY (MEMCACHE *MEMCACHE*) (VALUE 1) (USE-POOL *USE-POOL*))

Implements the INCR command. Increments the value of a key. Please read memcached documentation for more information key is a string value is an integer

MC-MAKE-MEMCACHE-INSTANCE (&KEY (IP 127.0.0.1) (PORT 11211) (NAME Cache Interface Instance) (POOL-SIZE 2))

Creates an instance of class MEMCACHE which represents a memcached server

MC-POOL-INIT (&KEY (MEMCACHE *MEMCACHE*))

Cleans up the pool for this particular instance of memcache & reinits it with POOL-SIZE number of objects required by this pool

MC-SERVER-CHECK (&KEY (MEMCACHE *MEMCACHE*))

Performs some basic tests on the Memcache instance and outputs a status string

MC-STATS (&KEY (MEMCACHE *MEMCACHE*) (USE-POOL *USE-POOL*))

Returns a struct of type memcache-stats which contains internal statistics from the memcached server instance. Please refer to documentation of memcache-stats for detailed information about each slot

MC-STORE (KEY DATA &KEY (MEMCACHE *MEMCACHE*) ((COMMAND COMMAND) SET) ((TIMEOUT TIMEOUT) 0) ((USE-POOL USE-POOL) *USE-POOL*))

Stores data in the memcached server using the :command command. key => key by which the data is stored. this is of type SIMPLE-STRING data => data to be stored into the cache. data is a sequence of type (UNSIGNED-BYTE 8) length => size of data memcache => The instance of class memcache which represnts the memcached we want to use. command => The storage command we want to use. There are 3 available : set, add & replace. timeout => The time in seconds when this data expires. 0 is never expire.

Private

EMPTY-QUEUE? (Q)

Are there no elements in the queue?

ENQUEUE-AT-END (Q ITEMS)

Add a list of items to the end of the queue.

MAKE-PROCESS-LOCK (NAME)

Create a named process lock object

MAKE-QUEUE

MC-GET-FROM-POOL (&KEY (MEMCACHE *MEMCACHE*))

Returns a pool object from pool.

MC-GET-FROM-POOL-WITH-TRY (&KEY (MEMCACHE *MEMCACHE*) (TRIES 5) (TRY-INTERVAL 1))

MC-STATS-BYTES (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-BYTES-READ (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-BYTES-WRITTEN (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-CMD-GET (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-CMD-SET (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-CONNECTION-STRUCTURES (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-CURR-CONNECTIONS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-CURR-ITEMS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-EVICTIONS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-GET-HITS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-GET-MISSES (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-LIMIT-MAXBYTES (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-PID (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-RAW (&KEY (MEMCACHE *MEMCACHE*) (USE-POOL *USE-POOL*))

Returns Raw stats data from memcached server to be used by the mc-stats function

MC-STATS-RUSAGE-SYSTEM (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-RUSAGE-USER (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-TIME (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-TOTAL-CONNECTIONS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-TOTAL-ITEMS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-UPTIME (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MC-STATS-VERSION (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

Q-ELEMENTS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

Q-KEY (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

Q-LAST (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

QUEUE-FRONT (Q)

Return the element at the front of the queue.

REMOVE-FRONT (Q)

Remove the element from the front of the queue and return it.

Undocumented

COPY-MEMCACHE-STATS (INSTANCE)

COPY-Q (INSTANCE)

MAKE-EMPTY-QUEUE

MAKE-MEMCACHE-STATS (&KEY ((PID DUM0) NIL) ((UPTIME DUM1) NIL) ((TIME DUM2) NIL) ((VERSION DUM3) NIL) ((RUSAGE-USER DUM4) NIL) ((RUSAGE-SYSTEM DUM5) NIL) ((CURR-ITEMS DUM6) NIL) ((TOTAL-ITEMS DUM7) NIL) ((BYTES DUM8) NIL) ((CURR-CONNECTIONS DUM9) NIL) ((TOTAL-CONNECTIONS DUM10) NIL) ((CONNECTION-STRUCTURES DUM11) NIL) ((CMD-GET DUM12) NIL) ((CMD-SET DUM13) NIL) ((GET-HITS DUM14) NIL) ((GET-MISSES DUM15) NIL) ((EVICTIONS DUM16) NIL) ((BYTES-READ DUM17) NIL) ((BYTES-WRITTEN DUM18) NIL) ((LIMIT-MAXBYTES DUM19) NIL))

MAKE-Q (&KEY ((KEY DUM20) #'IDENTITY) ((LAST DUM21) NIL) ((ELEMENTS DUM22) NIL))

MC-BENCHMARK (N DATA-SIZE &KEY (MEMCACHE *MEMCACHE*) (USE-POOL T) (ACTION WRITE))

MC-CHUCK-FROM-POOL (OBJECT MEMCACHE)

MC-DESTROY-POOL-ITEM (POOL-ITEM)

MC-MAKE-BENCHMARK-DATA (N)

MC-MAKE-POOL-ITEM (&KEY (MEMCACHE *MEMCACHE*))

MC-POOL-CLEANUP (MEMCACHE)

MC-POOL-GROW (MEMCACHE)

MC-POOL-GROW-REQUEST (MEMCACHE)

MC-PUT-IN-POOL (CONN &KEY (MEMCACHE *MEMCACHE*))

SETFMC-STATS-BYTES (NEW-VALUE INSTANCE)

SETFMC-STATS-BYTES-READ (NEW-VALUE INSTANCE)

SETFMC-STATS-BYTES-WRITTEN (NEW-VALUE INSTANCE)

SETFMC-STATS-CMD-GET (NEW-VALUE INSTANCE)

SETFMC-STATS-CMD-SET (NEW-VALUE INSTANCE)

SETFMC-STATS-CONNECTION-STRUCTURES (NEW-VALUE INSTANCE)

SETFMC-STATS-CURR-CONNECTIONS (NEW-VALUE INSTANCE)

SETFMC-STATS-CURR-ITEMS (NEW-VALUE INSTANCE)

SETFMC-STATS-EVICTIONS (NEW-VALUE INSTANCE)

SETFMC-STATS-GET-HITS (NEW-VALUE INSTANCE)

SETFMC-STATS-GET-MISSES (NEW-VALUE INSTANCE)

SETFMC-STATS-LIMIT-MAXBYTES (NEW-VALUE INSTANCE)

SETFMC-STATS-PID (NEW-VALUE INSTANCE)

SETFMC-STATS-RUSAGE-SYSTEM (NEW-VALUE INSTANCE)

SETFMC-STATS-RUSAGE-USER (NEW-VALUE INSTANCE)

SETFMC-STATS-TIME (NEW-VALUE INSTANCE)

SETFMC-STATS-TOTAL-CONNECTIONS (NEW-VALUE INSTANCE)

SETFMC-STATS-TOTAL-ITEMS (NEW-VALUE INSTANCE)

SETFMC-STATS-UPTIME (NEW-VALUE INSTANCE)

SETFMC-STATS-VERSION (NEW-VALUE INSTANCE)

MEMCACHE-STATS-P (OBJECT)

SETFQ-ELEMENTS (NEW-VALUE INSTANCE)

SETFQ-KEY (NEW-VALUE INSTANCE)

SETFQ-LAST (NEW-VALUE INSTANCE)

Q-P (OBJECT)

MACRO

Private

DEQUEUE (QUEUE)

ENQUEUE (QUEUE WHAT)

MC-WITH-POOL-Y/N (&BODY BODY)

Macro to wrap the use-pool/dont-use-pool stuff and the cleanup around a body of actual action statements

PROCESS-SLEEP (SECONDS)

Thread sleep for seconds

QUEUE-EMPTY-P (QUEUE)

WITH-PROCESS-LOCK ((LOCK) &BODY BODY)

Execute body wih the process lock grabbed, wait otherwise

SLOT-ACCESSOR

Private

CURRENTLY-IN-USE (OBJECT)

Pool objects currently in Use

SETFCURRENTLY-IN-USE (NEW-VALUE OBJECT)

Pool objects currently in Use

IP (OBJECT)

The IP address of the Memcached server this instance represents

SETFIP (NEW-VALUE OBJECT)

The IP address of the Memcached server this instance represents

MAX-CAPACITY (OBJECT)

Total capacity of the pool to hold pool objects

MEMCACHED-SERVER-STORAGE-SIZE (OBJECT)

Memory allocated to the Memcached Server

NAME (OBJECT)

Name of this pool

POOL-GROW-REQUESTS (OBJECT)

Pool Grow Request pending Action

SETFPOOL-GROW-REQUESTS (NEW-VALUE OBJECT)

Pool Grow Request pending Action

PORT (OBJECT)

The port on which the Memcached server this instance represents runs

SETFPORT (NEW-VALUE OBJECT)

The port on which the Memcached server this instance represents runs

TOTAL-CREATED (OBJECT)

Total pool objects created

SETFTOTAL-CREATED (NEW-VALUE OBJECT)

Total pool objects created

TOTAL-USES (OBJECT)

Total uses of the pool

SETFTOTAL-USES (NEW-VALUE OBJECT)

Total uses of the pool

Undocumented

CURRENT-SIZE (OBJECT)

SETFCURRENT-SIZE (NEW-VALUE OBJECT)

POOL (OBJECT)

SETFPOOL (NEW-VALUE OBJECT)

POOL-GROW-LOCK (OBJECT)

POOL-LOCK (OBJECT)

POOL-SIZE (OBJECT)

VARIABLE

Public

*USE-POOL*

Default value for the USE-POOL keyword parameter in memcached functions

Undocumented

*MEMCACHE*

Private

*POOL-GET-TRYS?*

If true then it will try to wait and sleep for a while if pool item in unavailable, if nil then will return immideatly

CLASS

Public

MEMCACHE

This class represents an instance of the Memcached server

Private

MEMCACHE-CONNECTION-POOL

A memcached connection pool object

MEMCACHE-STATS

The structure which holds the statistics from the memcached server. The fields are : field-name accessor-function documentation ---------- ----------------- ------------- pid mc-stats-pid Process id of this server process uptime mc-stats-uptime Number of seconds this server has been running time mc-stats-time current UNIX time according to the server version mc-stats-version Version string of this server rusage-user mc-stats-rusage-user Accumulated user time for this process rusage-system mc-stats-rusage-system Accumulated system time for this process curr-items mc-stats-curr-items Current number of items stored by the server total-items mc-stats-total-items Total number of items stored by this server ever since it started bytes mc-stats-bytes Current number of bytes used by this server to store items curr-connections mc-stats-curr-connections Number of open connections total-connections mc-stats-total-connections Total number of connections opened since the server started running connection-structures mc-stats-connection-structures Number of connection structures allocated by the server cmd-get mc-stats-cmd-get Cumulative number of retrieval requests cmd-set mc-stats-cmd-set Cumulative number of storage requests get-hits mc-stats-get-hits Number of keys that have been requested and found present get-misses mc-stats-get-misses Number of items that have been requested and not found evictions mc-stats-evictions Number of items removed from cache because they passed their expiration time bytes-read mc-stats-bytes-read Total number of bytes read by this server from network bytes-written mc-stats-bytes-written Total number of bytes sent by this server to network limit-maxbytes mc-stats-limit-maxbytes Number of bytes this server is allowed to use for storage.

Undocumented

Q

CONDITION

Private

Undocumented

BAD-POOL-OBJECT

CANNOT-MAKE-POOL-OBJECT

MEMCACHE-POOL-EMPTY

MEMCACHED-SERVER-UNREACHABLE

CONSTANT

Private

Undocumented

+CRLF+

+MC-END+