redigo icon indicating copy to clipboard operation
redigo copied to clipboard

Implement client side caching

Open holykol opened this issue 5 years ago • 5 comments

This PR implements server-assisted client side caching introduced in Redis 6.0

~This is done entirely at a pool level by running a separate goroutine that subscribes to invalidation broadcasts. Command responses are, again, cached by middleware at a pool level.~

This is done via new Cacher struct in redisx package.

TODO:

  • [x] Cache size limit
  • [x] Broadcasting mode
  • [x] Opt-in caching (via Matcher)
  • [x] Keeping track of TTL

closes #513

holykol avatar Oct 02 '20 09:10 holykol

Can someone review?

holykol avatar Oct 02 '20 09:10 holykol

@stevenh Great idea. I'm a little embarrassed I haven't thought of that before I started trying to fit more code into redis.Pool. Give me some time.

holykol avatar Oct 04 '20 20:10 holykol

Didn't mean to close this, but fine. Take a look at now @stevenh

holykol avatar Oct 04 '20 22:10 holykol

OK, I've gave up on trying to come up with abstraction for caching other data types. It's too much work for potentially useless feature:

  1. Implementing this feature basically means re-implementing big chunk of Redis functionality locally.
  2. Hashes, lists and sets change too fast to benefit from caching.
  3. My guess is that most people using Cacher will just store json/protobuf/gob/bare serialized data structures and will not care about other types.

@stevenh Can this be merged with it's current feature set?

holykol avatar Oct 13 '20 21:10 holykol

Just a quick note to say I haven't had chance to look at this yet, hopefully soon

stevenh avatar Oct 19 '20 08:10 stevenh