Skip to content

Instantly share code, notes, and snippets.

@ajtatum
Created January 19, 2021 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajtatum/f07593b42f701b67907ec54417cffa7d to your computer and use it in GitHub Desktop.
Save ajtatum/f07593b42f701b67907ec54417cffa7d to your computer and use it in GitHub Desktop.
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