Created
January 19, 2021 20:51
-
-
Save ajtatum/f07593b42f701b67907ec54417cffa7d to your computer and use it in GitHub Desktop.
Get Redis Cache Keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<List<string>> GetCacheKeys() | |
{ | |
var cacheKeys = new List<string>(); | |
var endpoints = Connection.GetEndPoints(); | |
var keys = Connection.GetServer(endpoints.First()).KeysAsync(); | |
var enumerator = keys.GetAsyncEnumerator(); | |
while (await enumerator.MoveNextAsync()) | |
{ | |
var key = enumerator.Current; | |
cacheKeys.Add(Convert.ToString(key)); | |
} | |
await enumerator.DisposeAsync(); | |
return cacheKeys; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment