【问题标题】:Why does RedisManager property removed from ServiceStack/Service.cs file?为什么从 ServiceStack/Service.cs 文件中删除 RedisManager 属性?
【发布时间】:2018-02-12 16:20:38
【问题描述】:

之前我们在 4.0.50 版本中有一个 RedisManager 属性,但在最新版本中,这个属性被删除了。谁能知道它为什么被删除?它的替代品是什么?

【问题讨论】:

    标签: redis connection servicestack servicestack.redis


    【解决方案1】:

    为了兼容多租户,RedisManager 被替换为 Redis property,它从 GetRedisClient() 解析一个新的 IRedisClient 实例,其行为可以在您的 AppHost 中被覆盖。这也减少了样板,因为您可以直接从您的服务访问 Redis 实例,例如:

    Redis.SetValue("foo", "bar");
    var bar = Redis.GetValue("foo");
    

    如果需要,RedisManager 属性仍然可以通过添加公共属性在您的服务中访问,就像任何其他依赖项一样:

    public IRedisClientsManager  RedisManager { get; set; }
    

    【讨论】:

    • 感谢@mythz 的回复。
    猜你喜欢
    • 1970-01-01
    • 2018-07-21
    • 2013-02-20
    • 1970-01-01
    • 2016-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-12
    相关资源
    最近更新 更多