Skip to content

Instantly share code, notes, and snippets.

@tiagosalgado
Created October 17, 2017 08:25
Show Gist options
  • Save tiagosalgado/44282da4f26388bdeadf5dcf228784bc to your computer and use it in GitHub Desktop.
Save tiagosalgado/44282da4f26388bdeadf5dcf228784bc to your computer and use it in GitHub Desktop.
delete all or single key
public void Delete(string key = null)
{
var endpoints = Connection.GetEndPoints();
foreach (var endpoint in endpoints)
{
var server = Connection.GetServer(endpoint);
if (string.IsNullOrWhiteSpace(key))
{
var keys = server.Keys(pattern: $"{_options.InstanceName}*", pageSize: 2000);
foreach (var k in keys)
{
server.Multiplexer.GetDatabase().KeyDelete(k);
}
}
else
{
server.Multiplexer.GetDatabase().KeyDelete(RedisKey(key));
}
}
}
@tiagosalgado
Copy link
Author

tiagosalgado commented Oct 17, 2017

StackExchange.Redis.RedisTimeoutException: 'Timeout performing SCAN, inst: 15, queue: 1, qu: 1, qs: 0, qc: 0, wr: 0, wq: 1, in: 0, ar: 0, clientName: xyz, serverEndpoint: Unspecified/.redis.cache.windows.net:6380 (Please take a look at this article for some common client-side issues that can cause timeouts: http://stackexchange.github.io/StackExchange.Redis/Timeouts)'

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