clojurewerkz / spyglass

A Clojure Memcached client (also: Couchbase, Kestrel). Built on top of SpyMemcached, supports ASCII and binary protocols, strives to be 100% feature complete.
http://clojurememcached.info
67 stars 17 forks source link

get-and-touch inconsistencies #28

Closed rwilson closed 8 years ago

rwilson commented 8 years ago

The current implementation of get-and-touch breaks the convention of other operation fns by exposing the returned net.spy.memcached.CASValue directly to the caller.

Example:

user> (mc/get-and-touch c "foo" 300)
#object[net.spy.memcached.CASValue 0x4bd21f9b "{CasValue 2089/bar}"]

Internally, this is the same spymemcached response as gets, except for gets it's transformed to a map with keys #{:cas :value}.

Example:

user> (mc/gets c "foo")
{:value "bar", :cas 2}

Having get-and-touch semantically mimic get and introducing a gets-and-touch that mimics gets would probably be the simplest, but that aside was there a reason for this inconsistency or would a pull request be welcome?

I was thinking of adding a convenience fn async-get-and-touch as well, which is missing.

michaelklishin commented 8 years ago

@rwilson I don't think there is a big idea behind the difference.

michaelklishin commented 8 years ago

Yes, a pull request would be welcome :)

rwilson commented 8 years ago

Resolved with merge.