EasyCaching icon indicating copy to clipboard operation
EasyCaching copied to clipboard

Support removing cache keys by pattern

Open xsoheilalizadeh opened this issue 3 years ago • 1 comments

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.

xsoheilalizadeh avatar Sep 15 '22 09:09 xsoheilalizadeh

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.

catcherwong avatar Sep 16 '22 00:09 catcherwong

Hi @catcherwong, did you have time to look into the PR?

xsoheilalizadeh avatar Oct 18 '22 07:10 xsoheilalizadeh

@xsoheilalizadeh In the last review, I pointed out some problems, you should fix them. 😄

catcherwong avatar Oct 18 '22 09:10 catcherwong

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.

xsoheilalizadeh avatar Oct 20 '22 07:10 xsoheilalizadeh

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.

timschwallie avatar Jan 31 '23 18:01 timschwallie