読者です 読者をやめる 読者になる 読者になる

libmemcachedでcas値を取得する

libmemcached

memcached_fetch_resultでmemcached_result_stを取得した後、memcached_result_casでcas値を取るというのはヘッダーファイルのAPIを見ていて分かったのですが、memcached_getではなく、memcached_mgetを呼んでからmemcached_fetch_resultを呼ばなくてはいけないということが分からず大ハマリ。

manにもちゃんと書いてありますね。先をこれを読めと。

memcached_fetch() is used to fetch an individual value from the server.
memcached_mget() must always be called before using this method. You
must pass in a key and its length to fetch the object. You must supply
three pointer variables which will give you the state of the returned
object. A uint32_t pointer to contain whatever flags you stored with the value,
a size_t pointer which will be filled with size of of the object, and a
memcached_return_t pointer to hold any error. The object will be returned
upon success and NULL will be returned on failure. MEMCACHD_END is returned
by the *error value when all objects that have been found are returned.
The final value upon MEMCACHED_END is null. Values returned by
memcached_fetch() musted be free'ed by the caller. memcached_fetch() will
be DEPRECATED in the near future, memcached_fetch_result() should be used
instead.