Some questions about the behavior of AddInternal function #391
Replies: 4 comments 1 reply
-
The current quick solution is to call GetCacheItem function immediately after ServiceA AddOrUpdate, so that all cache items will be written to all handles, but this writing method will cause great ambiguity. I guess if the purpose is to control. can we set a direction for each Handle, ReadWrite, WriteOnly, and ReadOnly?
Will this help improve the robustness of the component? |
Beta Was this translation helpful? Give feedback.
-
Hey @xingwen1987, The read through logic of CacheManager is intentional to make it almost impossible to end up in a scenario where I write an item to first and second cache handle and then the 2nd write fails with a network error for example. Long story short, this design is like that to keep the implementation simple and have no risk for data errors. Now to your scenario. Anyways, the main reason to use Redis is to have a distributed cache in the first place. What you describe is distributing cache data onto multiple "nodes". |
Beta Was this translation helpful? Give feedback.
-
I'm sorry for not getting back to you sooner. I had a long National Day holiday, and now I am back to work.
First, I totally agree with your opinion on the mentioned multi-handle storage. Yes, we cannot guarantee that every handle will be work fine in real-time, and defensive code increases overall complexity. But in practice, if the user does not use CacheManager as a cache manager from the project beginning and want to integrate it, they need to replace a lot of cache-related logic and objects hidden in the business codes, which is a huge breaking change with full risk, this is a key obstacle!! From a practical perspective, if CacheManager can manage existing cache instances and share cache values with existing cache instances, it will increase its ability and reduce integration difficulty, wouldn't it be a win-win situation?
Our production environment has multiple Redis clusters, including RW (read-write) clusters for our own business and RO (read-only) clusters for obtaining data. Large-volume data synchronization in some scenarios is achieved through Redis, so our system will connect to many Redis. If CacheManager can use the Name field in CacheManager Settings as the target cache and set RW or RO role for each handle, combined with what I said above, CacheManager will simplify cache connections and operations from another dimension and increase the utilization rate of it. here is a sample: for RW: for RO: for set-up:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the feedback. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
As I understand it, if user add a cache to the CacheManager, the CacheManager should add cache item to each handle.
But the current implementation only add cache item into the last registered handle. [code here]
Here is a scenario, ServiceA is a cache write service, which registers a RuntimeCacheHandle and multiple RedisCacheHandle (Redis1 ~ Redis5) to write, and ServiceB is a cache read service, which registers a RuntimeCacheHandle and one RedisCacheHandle (Redis1).
if ServiceA use AddOrUpdate method to add a cache item, according to the current code logic, this cache item only write to Redis5, When ServiceB wants to get the cache item written by ServiceA from Redis1, this cache not exist because ServiceA not add this cache into Redis1.
I want to understand the intention of this design, looking forward to your reply.
Beta Was this translation helpful? Give feedback.
All reactions