Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete All Keys #502

Open
Edgaras91 opened this issue Oct 30, 2023 · 4 comments
Open

Delete All Keys #502

Edgaras91 opened this issue Oct 30, 2023 · 4 comments

Comments

@Edgaras91
Copy link

Description

How can I delete all keys with the correct prefix that was set up in set-up code.
For example:

UseRedis( options => options.DBConfig.KeyPrefix = "dev1"

I want to delete all keys that have the above prefix "dev1" without having to mention the KeyPrefix.

I was very surprised that IEasyCachingProvider.RemoveAllAsync() requires keys? What is the use case to use this? Could we have an overload that doesn't take keys as parameters?

I also don't want to use "Flush" method as I believe that will ignore the prefix and require admin config.

The sole reason we are trying this library, as opposed to IDistributedCache, is so we can have a way to clear all cache for the application.

IEasyCachingProvider

Specifications

  • Provider : IEasyCachingProvider
  • Serializer : Newtonsoft
  • System : Windows 11
@catcherwong
Copy link
Member

@Edgaras91 Thanks for your interest in this project.

You can have a try with RemoveByPatternAsync or RemoveByPrefixAsync

@Edgaras91
Copy link
Author

@Edgaras91 Thanks for your interest in this project.

You can have a try with RemoveByPatternAsync or RemoveByPrefixAsync

Could you give an example of how to do it? I could not find any good documentation on this. Our key has no structure. Star characters alone were rejected.

@Memoyu
Copy link
Contributor

Memoyu commented Nov 18, 2023

@Edgaras91 Thanks for your interest in this project.
You can have a try with RemoveByPatternAsync or RemoveByPrefixAsync

Could you give an example of how to do it? I could not find any good documentation on this. Our key has no structure. Star characters alone were rejected.

You can try to look at these unit test codes:
https://github.com/easycaching-contrib/ec-basetest/blob/main/src/EasyCaching.BaseTest/BaseCachingProviderTest.cs#L929

@Edgaras91
Copy link
Author

Edgaras91 commented Nov 18, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants