Created
October 17, 2017 08:25
-
-
Save tiagosalgado/44282da4f26388bdeadf5dcf228784bc to your computer and use it in GitHub Desktop.
delete all or single key
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 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)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)'