Using MichaCo\CacheManager with Redis4You and RedisLab redis server

294 Views Asked by At

https://github.com/MichaCo/CacheManager/issues/42

Hi. I'm using Redis4You hosted redis server. And the following configuration works fine. When the code comes to line Cache.Add("a", "b");, then it stucks there for an infinite time. When I monitor the Redis server I see the console with full of PING there.

static class Program
{
    static readonly ICacheManager<string> Cache = CacheFactory.Build<string>("Test", cbcp =>
    {
        cbcp.WithSystemRuntimeCacheHandle("testCache")
            .And
            .WithRedisConfiguration("redis", rcb =>
            {
                rcb.WithEndpoint("<XXX>", 1111)
                   .WithPassword("<YYY>")
                   .WithAllowAdmin()
                   .WithDatabase(1);
            })
            .WithMaxRetries(100)
            .WithRetryTimeout(10)
            .WithRedisBackPlate("redis")
            .WithRedisCacheHandle("redis", true);
    });
    static void Main(string[] args)
    {
        /* It stucks in the first line. */
        Cache.Add("a", "b");
        Console.ReadLine();
    }
}

I debugged the code and the LuaScripts provided by CacheManager library such as the one below causes an error:

local result=redis.call('HMSET', KEYS[1], 'value', ARGV[1], 'type', ARGV[2], 'expiration', ARGV[3], 'timeout', ARGV[4], 'created', ARGV[5])
if ARGV[3] ~= '0' and ARGV[4] ~= '0' then
    redis.call('PEXPIRE', KEYS[1], ARGV[4])
else
    redis.call('PERSIST', KEYS[1])
end
return result

... and this luascript is used on this part of code in CacheManager library RedisCacheHandler.cs LoadScripts() method;

var putLua = StackRedis.LuaScript.Prepare(ScriptPut);
putLua.Load(server);

So, What is the problem here? (I don't think it's the version because redis4you uses 2.4 and redislab uses 3.0.3 of redis.)

1

There are 1 best solutions below

0
On BEST ANSWER

Redis4You uses Redis v2.4 and RedisLab uses Redis v3.0.3 right now. So, the RedisLab server works perfectly but Redis4You is problematic since the Redis v2.4 doesn't support scripting.

CacheManager should fix this issue. By the way you can check this availability with IServer.Features.Scripting.