alastairtree / LazyCache

An easy to use thread safe in-memory caching service with a simple developer friendly API for c#
https://nuget.org/packages/LazyCache
MIT License
1.72k stars 159 forks source link

how do I clean the cache items by wildcard of a key #167

Closed neozhu closed 3 years ago

neozhu commented 3 years ago

I save the query cache by the paging parameters and field conditions. e.g. cache key :$"{entityName}-{pageIndex}-{pageSize}-{filters}" : "Customers-1-30-" I need to clean these cache items when I update customers data. so, I want call cache.Remove("Customers-*") or any other solutions?

I saw that "Method 2 - Cancellation Tokens (could also be used to dispose a range of items)", but I use MediatR CQRS pattern in my project, how to use CancellationTokenSource

alastairtree commented 3 years ago

This is a duplicate of https://github.com/alastairtree/LazyCache/issues/74 so i will close it. Have a look at that as I have already proposed a way to achieve what you want.

neozhu commented 3 years ago

thanks, I did it.