grails-redis 插件的配置

Configuration for grails-redis plugin

我正在尝试使用 grails-redis 插件,以便我可以实现分布式对象缓存。我的 BuildConfig 中有缓存和缓存-redis:

compile ':cache:1.1.8'
compile ":cache-redis:1.1.0"

我本地有redis 运行。我知道它在工作,因为如果我杀死 redis,grails 应用程序将无法连接到它。我没有找到的是当我不在 运行 本地时如何修改 redis 的配置。

docs here. I also looked through the source here里面没有任何东西,也没有发现任何值得注意的东西。

如何配置 Redis 设置(主机、端口、超时等)?

仔细查看插件本身的 CacheRedisGrailsPlugin.groovy。您将看到 redis 本身在插件设置的 doWithSpring 阶段配置,并从 redisCacheConfig 配置文件中读取主机、端口等内容。

因此,在您的 Config.groovy 中添加如下内容是完全可以接受的:

grails {
  cache {
    redis {
      hostName = 'localhost'
      port = 6379
      timeout = 2000
    }
  }
}