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

前端 未结 4 538
执念已碎
执念已碎 2021-01-31 14:54

I am using StackExchange.Redis client with Azure Redis Cache Service. Here is my class,

public class RedisCacheService : ICacheService
{
    private readonly ISe         


        
4条回答
  •  广开言路
    2021-01-31 15:27

    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, 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)

提交回复
热议问题