private void UpdateToRedis(ProductModel product) { using (var context = new RedisContext()) { var value = JsonConvert.SerializeObject(product); context.Database.StringSet(product.CacheKey, value); var searchKeys = context.GetKeys("ProductSearch-*"); foreach (var key in searchKeys) { context.Database.KeyDelete(key); } } }
private void DeleteFromRedis() { using (var context = new RedisContext()) { var cacheKey = new ProductModel() { ProductId = ID }.CacheKey; context.Database.KeyDelete(cacheKey); var searchKeys = context.GetKeys("ProductSearch-*"); foreach (var key in searchKeys) { context.Database.KeyDelete(key); } } }