1
Service1 -> Our Wrapper API service -> Redis
Service2 -> Our Wrapper API service -> Redis

Client side caching with Redis is very useful. Redis provides server push-based cache invalidation for client side cache in 2 modes:

  1. Default mode: Redis keeps a mapping of all clients(services) and the key they requested on the server side and sends requests for invalidation when data changes for keys.
  2. Broadcast mode: Sends invalidation to all clients whenever any key changes and expects clients to update their local cache.

Problem

We have a use case in which we are building a platform service over Redis for some use cases and exposing APIs for clients to consume. We want the clients should not directly talk to Redis and talk via our API.

  • The problem here is how would Redis server push based cache invalidation work?
  • How would cache invalidation requests reach the clients(services) when we have an API layer in between. We do not wish the clients to directly talk to Redis and talk only via an API, do not want to leak the database to the clients, want to keep it internal.

Question

Do I need to implement my own push based cache invalidation layer then? Maintain clients who connect to my API and garbage collect the dead ones etc...? Is there anything better I could do and use the Redis cache invalidation or extend it for this use case?

Alok Kumar Singh
  • 2,331
  • 3
  • 18
  • 37

1 Answers1

0

Either the Redis client moves to those wrapper services ( becoming the actual Redis clients), OR move the wrapper services into Redis as an extension that the clients connect to, OR move the wrappers into the consumers and the wrappers wrap the Redis client ( thereby continuing to enjoy the Redis client benefits)

  • by wrapper service i meant the middle service here: service -> wrapper service -> redis. Do you mean the same? – Alok Kumar Singh Jul 20 '22 at 08:54
  • Can you repharse it a bit. Your words are too confusing, it sounds like a (w)rap ! :) Thanks for the comment though! – Alok Kumar Singh Jul 20 '22 at 08:55
  • The problem with Redis client moving to consumers is we are exposing our database to consumers. We wanted Redis to be internal to the consumers. It is a platform service we are making for all the other microservices. We may want to switch away from Redis if need be later, want to keep it strictly internal. – Alok Kumar Singh Jul 20 '22 at 08:57