A R6RS Scheme library for dealing with the Memcached caching daemon. Currently it only supports Guile, more will be added shortly.
Right now, the library is a little simplistic. It only supports communicating with a single Memcached instance, and expects you to deal with bytevectors. It also does not currently support CAS values. A more Schemey API for expiration values may also be desirable.
But anyway, enough self-deprecation, you probably want the docs.
Users are expected to import the (memcached) library.
Some commands take an expiration time. This is a 32 bit integer, whose meaning depends on its size. If it is less than 60*60*24*30=2592000, then it specifies the number of seconds. If it is larger than this, it specifies a Unix Time at which to expire. Update commands treat 0 specially as a “no-expires” value, since there is little point in updating something for it to expire immediately.
Takes a host string, and a port number, and returns a new connection to that server.
Same as above, but defaults to localhost, port 11211.
Closes the connection to the server
Takes a memcached connection, and a key bytevector, and returns the bytevector value stored in memcached with that key. If there is no value with that key, #f is returned.
Takes a memcached connection, a key bytevector, a value bytevector, and an expiration time, and updates the value stored at that key to the argument value. Returns #t if it updates the value, #f if it does not.
The differences between the three are:
- memcached-set! always updates the value
- memcached-add! will only update the value if there is not one already stored at that key
- memcached-replace! will only updated the value if there is one already stored at that key
Similar to above, but there is no expiration date for the key-value pair.
Takes a memcached connection, and a key bytevector, and removes the value stored at memcached with that key. If there is no value associated with that key in memcached, it does nothing. Returns #t.
Takes a memcached connection, a key bytevector, and a value bytevector, and either prepends or appends the value argument to the value stored in memcached at that key. Returns #t if successful, or #f if there is no value in memcached at that key.
Takes a memcached connection, and returns a string specifying the version of the memcached server.
Takes a memcached connection, and removes all the keys-value pairs stored in it. Returns #t.
Takes a memcached connection, a key bytevector, a delta integer, an initial value integer, and an expiration time. It returns the value of incrementing (or decrementing) the integer value stored at that key by the delta amount. If the key does not exist, it is set to the initial value integer.
Similar to above, but defaults to not expiring the key.
Similar to above, but if the key is not found it does not set it to a value. Instead, if the keys is not found, it returns #f.
Similar to the above, but it defaults to incrementing/decrementing the key by 1.