Code: Select all
memcached_return
memcached_mget (memcached_st *ptr,
char **keys,
size_t *key_length,
unsigned int number_of_keys);
char *memcached_fetch (memcached_st *ptr,
char *key,
size_t *key_length,
size_t *value_length,
uint32_t *flags,
memcached_return *error);
memcached_mget asynchronously gets the passed keys' values, and memcached_fetch retrieves them one by one. However, when watching the server debug output, when memcached_fetch is called, it's reporting an error (either SERVER_END or PROTOCOL_ERROR, and I can find documentation for neither). However, I think that the problem is newlisp dies with a bus error and disconnects in the middle of a transaction.
Here is the function I'm using (it's not yet cleaned up):
Code: Select all
(define (get-keys list-keys , res)
(when MEMCACHED
(letn ((num-keys (length list-keys))
(keys (pack (trim (dup "lu " num-keys)) (map 'string list-keys)))
(lengths (pack (trim (dup "d " num-keys)) (map 'length (map 'string list-keys)))))
(setq MEMCACHED_RETURN (memcached_mget MEMCACHED keys lengths num-keys))
(when (= (result) "SUCCESS")
(setq res '())
(dolist (key list-keys)
(let ((key-length (length key))
(val-length 0)
(flags 0)
(val nil))
(setq val (memcached_fetch MEMCACHED
key (address key-length)
(address val-length) (address flags)
(address MEMCACHED_RETURN)))
(push (list key (get-string val)) res -1))))))
res)
Note: that 'result' function reads the error/status of MEMCACHED_RETURN. Success returns the string "SUCCESS", which suggests that the memcached_mget call succeeded.
Any ideas?
PS docs for libmemcached: http://docs.tangent.org/libmemcached/memcached.html