예제 #1
0
        /// <inheritdoc/>
        public async Task SetAsync(string key, ResponseCacheEntry entry, CancellationToken cancellationToken)
        {
            //HACK 设置值与设置过期时间不是原子性操作,可能存在残留。不影响缓存正确性,是否有必要进行删除?
            RedisKey redisKey = key;
            await _database.HashSetAsync(redisKey, new[] {
                new HashEntry(_contenTypeFieldName, entry.ContentType),
                new HashEntry(_bodyFieldName, entry.Body),
                new HashEntry(_expireFieldName, entry.Expire),
            });

            _ = _database.KeyExpireAsync(redisKey, DateTimeOffset.FromUnixTimeMilliseconds(entry.Expire).UtcDateTime);
        }
예제 #2
0
 /// <inheritdoc/>
 public Task SetAsync(string key, ResponseCacheEntry entry, CancellationToken cancellationToken)
 {
     _memoryCache.Set(key, entry, entry.GetAbsoluteExpirationDateTimeOffset());
     return(Task.CompletedTask);
 }
예제 #3
0
 /// <inheritdoc/>
 public void Set(string key, ResponseCacheEntry entry)
 {
     _boundedMemoryCache.Add(key, entry);
 }
 /// <inheritdoc/>
 public Task SetAsync(string key, ResponseCacheEntry entry, CancellationToken cancellationToken)
 {
     _hotDataCache.Set(key, entry);
     return _distributedCache.SetAsync(key, entry, cancellationToken);
 }