CacheManager icon indicating copy to clipboard operation
CacheManager copied to clipboard

ClearRegion not working for redis implementation

Open bigerock opened this issue 8 years ago • 17 comments

Although it "shouldn't" matter, First, I am using Redis in Azure. My configuration is as follows. It's two cache handles, Memory and Redis, with a Redis backplane.

var ret = CacheFactory.Build("memandrediscache", settings =>
        {
            settings
                .WithSystemRuntimeCacheHandle("inProcessCache")
                .EnableStatistics()
                .And
                .WithRedisConfiguration(redisKey, config => config
                   .WithAllowAdmin()
                   .WithConnectionTimeout(10000)
                   .WithEndpoint(endPointUrl, endPointPort)
                   .WithPassword(password)
                   .WithSsl()
                )
                .WithJsonSerializer(jsonSer, jsonDeSer)
                .WithMaxRetries(4) //from 1000
                .WithRetryTimeout(10000)
                .WithRedisBackplane(redisKey)
                .WithRedisCacheHandle(redisKey, true);
        });

When I try to clear the region, the following code gives a zero index result, meaning no hashKeys are found and therefore doesn't continue on to clear the region.

code location: CacheManager.StackExchange.Redis\RedisCacheHandle.cs > ClearRegion(string region){} > line 166 in the code i have... var hashKeys = this.connection.Database.HashKeys(region);

An example of one of the keys I'm trying to clear in Redis: "data:_cache.data.counts.dcsnav.316914602"

My code to clear the region is as follows:

var cache = CreateInMemoryCacheWithRedisBackplane(); // gets the CacheFactory.Build object from above cache.ClearRegion(region.ToLower()); //value of 'region' is 'data'

bigerock avatar Jun 15 '16 17:06 bigerock