/// <summary> /// Clears cache server with given clear criteria /// </summary> /// <param name="criteria">A query to filter cache keys, works with redis search characters</param> public void ClearCache(CacheClearQuery criteria) { var db = CacheEndpoint.GetDatabase(); foreach (var endPoint in CacheEndpoint.GetEndPoints()) { var server = CacheEndpoint.GetServer(endPoint); foreach (var redisKey in server.Keys(pattern: criteria.Pattern)) { Delete(db, new CacheKey(redisKey)); } } }
public void Set(CacheKey cacheKey, CacheValue cacheObj, CacheRule cacheRule) { var db = CacheEndpoint.GetDatabase(); db.StringSet(cacheKey.ToString(), cacheObj.Value, cacheRule.ExpiresIn); }
public void Delete(CacheKey cacheKey) { var db = CacheEndpoint.GetDatabase(); db.KeyDelete(cacheKey.ToString()); }
public CacheValue Get(CacheKey cacheKey) { var db = CacheEndpoint.GetDatabase(); return(new CacheValue(db.StringGet(cacheKey.ToString()))); }