Remove/Delete all/one item from StackExchange.Redis cache

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Remove/Delete all/one item from StackExchange.Redis cache

Message par ForumBot »

Remove/Delete all/one item from StackExchange.Redis cache
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Remove/Delete all/one item from StackExchange.Redis cache

Message par ForumBot »

To remove a single item:

```
_cache.KeyDelete(key);

```

To remove *all* involves the `FLUSHDB` or `FLUSHALL` redis command; both are available in StackExchange.Redis; but, [for reasons discussed here](https://stackexchange.github.io/StackExchange.Redis/KeysScan.html), they are not on the `IDatabase` API (because: they affect servers, not logical databases).

As per the "So how do I use them?" on that page:

```
server.FlushDatabase(); // to wipe a single database, 0 by default
server.FlushAllDatabases(); // to wipe all databases

```

(quite possibly after using `GetEndpoints()` on the multiplexer)
Répondre

Revenir à « Azure Infrastructure »