How to Clustering cache Keys or Search by multiple Tags in FusionCache? #380
Replies: 1 comment 2 replies
-
Hi @fuad-bassam , in general massive operations like "search by tag" are not really ok on distributed caches, because:
As an example, if I remember correctly even the SCAN command is disabled when Redis is used as a cloud service, for example of Azure Redis Cache, again because it is problematic for performance. If you are using Redis and really need such a method then yes I would suggest to use something like Redis sets, but again measure everything with real world load and watch out for performance impacts. Also remember that you can have 10 keys expiring at different times and add each of them at different times to the set, so when you'll get the set content back it may contain keys that do not exist anymore, or other problems like this. Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm using FusionCache with DistributedCache Ri in a .NET project to cache a large amount of data. I need to retrieve all cache entries that match specific tags efficiently.
Problem
FusionCache allows tagging cached and Removing it
RemoveByTag("tag123")
, but I couldn't find a method likeGetKeysByTagAsync()
to retrieve all keys associated with specific tags.Example scenario:
Cached items have tags Or split (Shard) Cache Keys like
Type1:Value2
,Type2:Value4
,Type3:Value2
andType4:Value3
, I want to retrieve all cache keys that belong to bothType2:Value4
andType3:Value2
.Questions
Would love to hear any best practices or alternative approaches for handling this in FusionCache! 🚀
Beta Was this translation helpful? Give feedback.
All reactions