1 Low level Interface
memcached-pool?
memcached
key?
value?
cas?
uint4?
uint8?
empty-cas
memcached-get
memcached-set!
memcached-add!
memcached-replace!
memcached-delete!
memcached-incr!
memcached-decr!
memcached-append!
memcached-prepend!

memcached

Jay McCarthy <jay@racket-lang.org>

 (require (planet jaymccarthy/memcached:1:0))

This package provides an interface to memcached.

1 Low level Interface

At the moment, only a low-level interface is provided.

(memcached-pool? x)  boolean?
  x : any/c
Identifies memcached pool structures.

(memcached ip port ... ...)  memcached-pool?
  ip : string?
  port : (and/c exact-nonnegative-integer? (integer-in 1 65535))
Establishes TCP connections to the specified servers at the respective ports. However, only the first connection is used.

This function should be modified to support UDP connections and its internals should be adapted to use all connections in the recommended way.

key? : contract?
Corresponds to bytes?.
value? : contract?
Corresponds to bytes?.
cas? : contract?
Corresponds to bytes? guaranteed to be 8 bytes long.
uint4? : contract?
Corresponds to exact-nonnegative-integer?.
uint8? : contract?
Corresponds to exact-nonnegative-integer?.
empty-cas : cas?
The null CAS, suitable for use when the CAS is unknown or when you don’t care.

(memcached-get mp k)  
(or/c false/c value?) cas?
  mp : memcached-pool?
  k : key?
Retrieves the key’s value and CAS.

(memcached-set! mp    
  k    
  v    
  [#:expiration exp    
  #:cas cas])  (or/c false/c cas?)
  mp : memcached-pool?
  k : key?
  v : value?
  exp : uint4? = 0
  cas : cas? = empty-cas
Sets the key to the value with the expiration time if the CAS is still the same, returning the new CAS.
(memcached-add! mp k v [#:expiration exp])  (or/c false/c cas?)
  mp : memcached-pool?
  k : key?
  v : value?
  exp : uint4? = 0
Sets the key to the value with the expiration time if it is not bound, returning the new CAS.
(memcached-replace! mp    
  k    
  v    
  [#:expiration exp    
  #:cas cas])  (or/c false/c cas?)
  mp : memcached-pool?
  k : key?
  v : value?
  exp : uint4? = 0
  cas : cas? = empty-cas
Sets the key to the value with the expiration time if the CAS is still the same and it is bound, returning the new CAS.

(memcached-delete! mp k [#:cas cas])  boolean?
  mp : memcached-pool?
  k : key?
  cas : cas? = empty-cas
Deletes the key if the CAS is still the same.

(memcached-incr! k    
  [#:amount amt    
  #:initial init    
  #:expiration exp    
  #:cas cas])  (or/c false/c uint8?)
  k : key?
  amt : uint8? = 1
  init : false/c = #f
  exp : uint4? = 0
  cas : cas? = empty-cas
Increments the key’s value by the amount with the expiration time if the CAS is still the same and it is bound, returning the new value as an integer.
(memcached-decr! k    
  [#:amount amt    
  #:initial init    
  #:expiration exp    
  #:cas cas])  (or/c false/c uint8?)
  k : key?
  amt : uint8? = 1
  init : false/c = #f
  exp : uint4? = 0
  cas : cas? = empty-cas
Decrements the key’s value by the amount with the expiration time if the CAS is still the same and it is bound, returning the new value as an integer.

These two functions have a more restrictive contract on the initial value than the API because I do not understand them enough to decide if the contract should be uint8? or value?.

(memcached-append! k v [#:cas cas])  (or/c false/c cas?)
  k : key?
  v : value?
  cas : cas? = empty-cas
Appends the value to the key’s current value if the CAS is still the same, returning the new CAS.
(memcached-prepend! k v [#:cas cas])  (or/c false/c cas?)
  k : key?
  v : value?
  cas : cas? = empty-cas
Prepends the value to the key’s current value if the CAS is still the same, returning the new CAS.