Skip to content

Instantly share code, notes, and snippets.

@mythz

mythz/main.cs

Forked from alfredoPacheco/main.cs
Created Jul 1, 2020
Embed
What would you like to do?
Redis Redis/Memory RemoveAll repro
using System;
using ServiceStack;
using ServiceStack.Text;
using ServiceStack.Redis;
using ServiceStack.DataAnnotations;
using ServiceStack.Caching;
var redisManager = new RedisManagerPool("localhost:6379");
var redis = redisManager.GetClient();
redis.FlushAll();
var cache = redisManager.GetCacheClient().WithPrefix("sample");
var memCache = new MemoryCacheClient().WithPrefix("sample");
cache.Set("siafracc_QUERY_Deposit__Query_Deposit_10_1", "A");
cache.Set("siafracc_QUERY_Deposit__0_1___CUSTOM", "B");
memCache.Set("siafracc_QUERY_Deposit__Query_Deposit_10_1", "A");
memCache.Set("siafracc_QUERY_Deposit__0_1___CUSTOM", "B");
var keys = cache.GetKeysStartingWith("siafracc_QUERY_Deposit");
var memKeys = memCache.GetKeysStartingWith("siafracc_QUERY_Deposit");
cache.RemoveAll(keys);
memCache.RemoveAll(memKeys);
var newKeys = cache.GetKeysStartingWith("siafracc_QUERY_Deposit");
var memNewKeys = memCache.GetKeysStartingWith("siafracc_QUERY_Deposit");
"oldKeys:".Print();
keys.PrintDump();
"newKeys:".Print();
newKeys.PrintDump();
"memNewKeys:".Print();
memNewKeys.PrintDump();
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.Memory" version="4.5.4" targetFramework="net45" />
<package id="ServiceStack.Text" version="5.9.0" targetFramework="net45" />
<package id="ServiceStack.Client" version="5.9.0" targetFramework="net45" />
<package id="ServiceStack.Interfaces" version="5.9.0" targetFramework="net45" />
<package id="ServiceStack.Redis" version="5.9.0" targetFramework="net45" />
<package id="ServiceStack" version="5.9.0" targetFramework="net45" />
</packages>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment