【问题标题】:Using MichaCo\CacheManager with Redis4You and RedisLab redis server将 MichaCo\CacheManager 与 Redis4You 和 RedisLab redis 服务器一起使用
【发布时间】:2016-02-11 16:32:06
【问题描述】:

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

嗨。我正在使用 Redis4You 托管的 redis 服务器。以下配置工作正常。当代码到达Cache.Add("a", "b"); 行时,它会无限期地停留在那里。当我监控 Redis 服务器时,我看到控制台中充满了 PING。

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();
    }
}

我调试了CacheManager库提供的代码和LuaScripts,如下面的导致错误:

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

...而且这个luascript用在CacheManager库RedisCacheHandler.cs LoadScripts()方法的这部分代码上;

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

那么,这里有什么问题? (我觉得不是版本,因为redis4you用的是2.4,redislab用的是redis的3.0.3。)

【问题讨论】:

标签: redis stackexchange.redis redis-server cachemanager


【解决方案1】:

Redis4You 使用 Redis v2.4,而 RedisLab 现在使用 Redis v3.0.3。因此,RedisLab 服务器完美运行,但 Redis4You 存在问题,因为 Redis v2.4 不支持脚本。

CacheManager 应该可以解决这个问题。顺便说一句,您可以使用 IServer.Features.Scripting 检查此可用性。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-26
    • 1970-01-01
    • 2014-03-10
    • 2015-06-14
    • 2016-09-24
    相关资源
    最近更新 更多