chickadee » memcached

memcached

Description

The memcached library contains procedures that implement the client side of the Memcached protocol. Memcached is a distributed in-memory key-value store for small chunks of arbitrary data.

The Chicken memcached library uses the base64-encode procedure from the base64 library to compute hashes for given key objects, and the read and write procedures to store Scheme objects in a Memcached instance.

Repository

This egg is hosted on the CHICKEN Subversion repository:

https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/memcached

If you want to check out the source code repository of this egg and you are not familiar with Subversion, see this page.

Library procedures

connect HOST PORTprocedure

Connects to the Memcached server instance running on HOST at PORT. Returns a server handle object (see below).

disconnect Hprocedure

Disconnects the given server handle from its host.

stats Hprocedure

Invokes the statistics command on the server indicated by handle H. Returns an alist of statistics information.

set H KEY VAL #!optional HASHprocedure

Set storage command on the server indicated by handle H. KEY and VAL can be any serializable Scheme object. The hash value for KEY is obtained by the HASH procedure, which defaults to the one provided by the Chicken SRFI-69 implementation. Returns #t on success, #f otherwise.

add H KEY VAL #!optional HASHprocedure

Add storage command on the server indicated by handle H. KEY and VAL can be any serializable Scheme object. The hash value for KEY is obtained by the HASH procedure, which defaults to the one provided by the Chicken SRFI-69 implementation. Returns #t on success, #f otherwise.

replace H KEY VAL #!optional HASHprocedure

Replace storage command on the server indicated by handle H. KEY and VAL can be any serializable Scheme object. The hash value for KEY is obtained by the HASH procedure, which defaults to the one provided by the Chicken SRFI-69 implementation. Returns #t on success, #f otherwise.

get H KEY #!optional HASHprocedure

Get command on the server indicated by handle H. The hash value for KEY is obtained by the HASH procedure, which defaults to the one provided by the Chicken SRFI-69 implementation. Returns the deserialized object if the key is found, #f otherwise.

delete H KEY #!optional HASHprocedure

Delete command on the server indicated by handle H. The hash value for KEY is obtained by the HASH procedure, which defaults to the one provided by the Chicken SRFI-69 implementation. Returns #t on success, #f otherwise.

incr H KEY DELTA #!optional HASHprocedure

Increment key command on the server indicated by handle H. The hash value for KEY is obtained by the HASH procedure, which defaults to the one provided by the Chicken SRFI-69 implementation. Returns #t on success, #f otherwise.

decr H KEY DELTA #!optional HASHprocedure

Decrement key command on the server indicated by handle H. The hash value for KEY is obtained by the HASH procedure, which defaults to the one provided by the Chicken SRFI-69 implementation. Returns #t on success, #f otherwise.

Server handles

All procedures in this library operate on a server handle object, which is created by the connect procedure. The following predicate and accessors are available for accessing a server handle:

server-handle? Hprocedure

Returns #t is H is a Memcached server handle, #f otherwise.

server-handle-host Hprocedure

Returns the host name of the given handle.

server-handle-port Hprocedure

Returns the port number of the given handle.

Convenience macro

(with-server-connection H HOST PORT CMD ...)syntax

A convenience macro for creating and destroying a connection for a given set of commands. H is the name of the server handle that will be created. The connection is created before any of the forms CMD... are executed, and is destroyed after the last command is executed.

Example

(with-server-connection h "localhost" 11211
     (let ((foo 4))
       (let ((success (set h "foo" foo)))
	 (let ((foo1 (get h "foo")))
	   (equal? foo foo1)))))

Version History

License

Based on the Haskell Memcached library by Evan Martin <martine@danga.com>.

 Copyright 2011-2019 Ivan Raikov and Seth Alves.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are
 met:
 
 Redistributions of source code must retain the above copyright
 notice, this list of conditions and the following disclaimer.
 
 Redistributions in binary form must reproduce the above copyright
 notice, this list of conditions and the following disclaimer in the
 documentation and/or other materials provided with the distribution.
 
 Neither the name of the author nor the names of its contributors may
 be used to endorse or promote products derived from this software
 without specific prior written permission.
 
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 OF THE POSSIBILITY OF SUCH DAMAGE.

Contents »