redigo
redigo copied to clipboard
Implement client side caching
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
Can someone review?
@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.
Didn't mean to close this, but fine. Take a look at now @stevenh
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:
- Implementing this feature basically means re-implementing big chunk of Redis functionality locally.
- Hashes, lists and sets change too fast to benefit from caching.
- 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?
Just a quick note to say I haven't had chance to look at this yet, hopefully soon