지정한 만료 날짜 이후에 내 C# 서비스에서 전체 캐시를 지우거나 플러시하는 방법이 있는지 알고 싶습니다. C#에서 어떻게 이것을 할 수 있습니까?ClearExchangeExchange.Redis 구성 가능한 만료가있는 캐시
// library
using StackExchange.Redis;
public class RedisCacheService
{
// Fields
ConnectionMultiplexer _Redis = null;
IDatabase _RedisDB = null;
// ctor
public RedisCacheService(String redisConnectionString) // , DateTime ExpiryDate ? - Extracted from config
{
try
{
if (String.IsNullOrEmpty(redisConnectionString))
{
throw new Exception("The 'redisConnectionString' parameter is unassigned");
}
this._Redis = ConnectionMultiplexer.Connect(redisConString);
if (_Redis == null)
{
throw new Exception("_Redis object not initialized");
}
this._RedisDB = _Redis.GetDatabase();
// I need to set some sort of expiry config here in the constructor.
// The redisConnectionString is passed through when an instance of this class is created in the host startup and
// the redisConnectionString is extracted from the config.
}
catch (Exception e)
{
throw new Exception(e);
}
}
}
C#을 내가 실제로 객체 캐시를 채울 수 있지만 오히려 글로벌 캐시 맑은 용액을 할 때 내가 만료에 전달할 수있는 유사한 솔루션을 보았다.
도움이나 의견을 보내 주시면 감사하겠습니다.
'키 공간 이벤트'에 대한 이벤트를 알지 못했습니다. 이 굉장한 물건 남자 감사드립니다. – ThatAwesomeCoder
np;) 유일한 단점은 redis 서버에서 명시 적으로 활성화해야한다는 것입니다. 구성이나 명령 행을 통해 수행 할 수 있습니다. 'CONFIG SET notify-keyspace-events Exe'가 필요합니다. – MichaC