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

why use intanceId? #2

Closed yafacex closed 1 year ago

yafacex commented 2 years ago

different process use diffrent instanceId, is it a waste of memory?

Pacific73 commented 1 year ago

To be more accurate, the instance you created can be shared among different processes, since db instance itself can be accessed in different processes because the cache instance is attached to the db instance. The purpose of instance id is to handle the situation where you use 2 cache instances on 2 different db instances while only using 1 shared redis server for caching. in that case, keys would have conflicts if we don't add an instance id prefix before key names for isolating.