Support removing cache keys by pattern
Fixes #399
Only Memcached is not supported among the providers, if you have any ideas on how we can implement it I'd like to hear them.
Only Memcached is not supported among the providers, if you have any ideas on how we can implement it I'd like to hear them.
I don't have a good idea about Memcached as well. NotSupportedException is fine.
Hi @catcherwong, did you have time to look into the PR?
@xsoheilalizadeh In the last review, I pointed out some problems, you should fix them. 😄
Thanks @catcherwong, I addressed the requested changes.
P.S: I am not sure which last review you mean because I didn't receive any reviews until 2 days ago.
For memcached would probably need to maintain a key of keys, aka allKeys. Then on pattern removal, grab all the keys and run through them for pattern match. At the same time, you may need to implement a locking mechanism. allKeys would be a hotspot. So might need to spread it out into multiple 'allkeys' based on some logic, like key. Parallel.ForEach might be a way to speed it up using multiple threads. Keys in 'allKeys' may not exist because of evictions. Might be able to eek out some performance by adding a field holding the Fixed expiration date. Have Fixed expiration date populated it that's the policy in use and check it.
To make it consistent, you would need to move this pattern to the other Caches. Slows things down a touch on create, logical removals, etc.
Note, this does begin to lead into being able to support dependent Keys.