bradfitz / gomemcache

Go Memcached client library #golang
Apache License 2.0
1.76k stars 459 forks source link

Support get-and-touch commands #77

Open arodland opened 6 years ago

arodland commented 6 years ago

gat and gats were added to the ASCII protocol in memcached 1.5.3 (2017-11-04). They work like get / gets and have the same response format, but have a new first argument that is an expiration time in the same format as touch.

I can implement this, the approach I would take would be:

  1. Add a param and a conditional in getFromAddr so that it supports either gets or gats using the same code path.
  2. Refactor most of GetMulti into a private method, so that the public method that's left is similarly as thin as Get or Set.
  3. Add an expiration param to the new private getMulti as well.
  4. Add GetAndTouch(key string, seconds int32) and GetAndTouchMulti(keys []string, seconds int32).

If that sounds alright, then I'll go ahead, but I figured I would check in on approach first.

ntindall commented 6 years ago

@arodland any immediate plans to do this? I think this would be a great add.