Closed murtymaganti closed 10 months ago
@MichaCo I am having significant performance issue using Dictionary Handle. Retrieving an item from cache manager is taking around 800 milliseconds. If I use a dictionary inside the class, it takes less than 1 millisecond. I assume dictionary handle also uses a dictionary internally then why is it so slow.
I simply use the below to capture the access time. Difference between endTime and startTime averages around 800 milliseconds
DateTime startTime = DateTime.Now; object value = _cacheManager.get(region, key); DateTime endTime = DateTime.Now;
If I try same with a internal dictionary like below, the different between start and end time is less than a millisecond.
DateTime startTime = DateTime.Now; if(myDictionary.ContainsKey(key)){ object value = myDictionary[key]; } DateTime endTime = DateTime.Now;
Is the slowness in dictionary handle expected? How to improve the performance? Only difference between the two is that I store the entire myDictionary in cache handle as as one time to avoid creating millions of keys.
@murtymaganti you must be doing something else, just using the dictionary cache will be a lot faster than 800ms, you can do millions of gets per second against a dictionary. Most likely you cache is not just using one dictionary layer? Or something else in your code is fishy. I cannot reproduce your problem with just the code provided obviously.
Hi,
I have a question on how items are added to cache layers. My understanding is that the first time an item is added, Cache manager adds the item only to the bottom layer and only on subsequent read it adds to the top layer. Is there a way the item can be added to all layers the very first time?
Thanks Murty