We have a multi-tenant NodeJS application and we are now adding a cache layer for some of our data.
We are aiming to use Redis cache with redis package and we are trying to check our options for supporting multi-tenancy with two main points in mind:
- Securing data.
- Purging the old data in tenant level.
Our investigation results so far are that we can use separate Redis instances for each tenant - which is not a good solution for us.
Another option we found is to namespace our keys with the "tenant_id:" prefix. This option solves the first point - data is secured now, but we still have the second point to resolve.
Our use case for this point is that one tenant can put a major amount of data which will fill the cache and push out other tenants' data. We want to define our LRU in tenant level, that is - when new data is added to the cache it will evict only the last recently used data of the same tenant.
Any suggestions?