Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get Redis Cache Keys
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