【问题标题】:How to set redis "session key prefix" using RedissonSessionManager如何使用 RedissonSessionManager 设置 redis “会话密钥前缀”
【发布时间】:2018-07-30 09:04:13
【问题描述】:

我想使用“redisson-tomcat”库在 redis 中存储 tomcat 会话。但是我需要在将会话存储在 redis 之前添加键前缀。在 redis 中存储会话时,有什么方法可以添加会话密钥前缀?根据我的发现,我需要使用 tomcat 配置“RedissonSessionManager”。像下面这样

<Manager className="org.redisson.tomcat.RedissonSessionManager" configPath="${catalina.base}/redisson.conf" readMode="MEMORY" updateMode="DEFAULT"/>

看起来很多想法都可以使用“redisson.conf”文件进行配置,但是我没有看到任何添加密钥前缀的配置。

谁能帮我解决这个问题?

【问题讨论】:

    标签: java tomcat servlets redis redisson


    【解决方案1】:

    redison-tomcat 目前似乎没有此功能,作为解决方法,我扩展了 RedissonSessionManager 并覆盖了 getMap 方法以设置自定义会话密钥前缀 RedissonSessionManager::getMap。我还向他们发送了包含此功能的拉取请求。如果有人感兴趣,你也可以看看pull request

    【讨论】:

      【解决方案2】:

      尝试在代码中添加 keyprefix。

      <Manager className="org.redisson.tomcat.RedissonSessionManager"
            configPath="${catalina.base}/redisson.conf" readMode="MEMORY" updateMode="DEFAULT" keyPrefix="yourPrefix" />
      

      【讨论】:

      • 一个好的答案有一个更好的解释How do I write a good answer?
      • 这个“keyPrefix”功能是我的贡献,看看我之前的评论:)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-05
      • 1970-01-01
      • 2013-12-13
      • 2017-12-10
      • 1970-01-01
      • 2016-05-21
      • 1970-01-01
      相关资源
      最近更新 更多