Pacific73 / gorm-cache

gorm v2的即插即用、无需修改代码的旁路缓存。An easy-to-use look-aside cache solution for gorm v2 users.
Apache License 2.0
111 stars 29 forks source link

How to support Tenant? #22

Closed rts-gordon closed 1 year ago

rts-gordon commented 1 year ago

Hi @Pacific73 Can gorm-chche support Tenant?

For example: there are many tenant in my system, they can access the same Table:task with different product Id. When Tenant A list task list A with product A Id, if Tenant B update his task B, this operation will not remove task list A in Cache.

In another word, A tenant Create/Update/Delete operations should only affect cached data associated with that tenant, can't affect other tenant cache data.

Thank you.

Pacific73 commented 1 year ago

If you mean multiple tenants in ONE SINGLE PROCESS, then the answer is WE CANNOT SUPPORT. You can use multiple db instances, then attach them each with a GormCache.

In another word, A tenant Create/Update/Delete operations should only affect cached data associated with that tenant, can't affect other tenant cache data. ↓ This is not a usual and correct way of dealing with data accessed by multiple clients. Why not operating them in memory rather than database?