Redison hibernate缓存模块在多个容器中共享相同的数据吗?

gstyhher  于 2021-06-09  发布在  Redis
关注(0)|答案(1)|浏览(411)

我们想使用redisson hibernate项目https://github.com/redisson/redisson/tree/master/redisson-hibernate 支持redis二级缓存。
我使用相同的redis数据库在多个容器中测试了redisson hibernate模块。我们在同一个redis中使用同一个数据库。但它不共享相同的数据。第一个容器中的java应用程序看不到第二个容器中的java应用程序所做记录的更新。每个java应用程序都有自己的记录版本。
Redison hibernate缓存模块是否可以在多个容器中共享相同的数据?
redisson.yaml文件内容:

singleServerConfig:
  idleConnectionTimeout: 10000
  connectTimeout: 10000
  timeout: 3000
  retryAttempts: 3
  retryInterval: 1500
  password: null
  subscriptionsPerConnection: 5
  clientName: null
  address: "redis://127.0.0.1:6380"
  subscriptionConnectionMinimumIdleSize: 1
  subscriptionConnectionPoolSize: 50
  connectionMinimumIdleSize: 24
  connectionPoolSize: 64
  database: 0
  dnsMonitoringInterval: 5000
threads: 16
nettyThreads: 32
codec: !<org.redisson.codec.FstCodec> {}
transportMode: "NIO"

我们使用hibernate与postgresql数据库进行交互,这是我们的hibernate连接属性文件内容:

hibernate.connection.url=jdbc:postgresql://localhost:5439/testdb
hibernate.connection.username=testdb
hibernate.connection.password=testdb567
hibernate.connection.driver_class=org.postgresql.Driver
hibernate.connection.pool_size=10
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory
hibernate.current_session_context_class=thread
hibernate.show_sql=true
hibernate.cache.region.factory_class=org.redisson.hibernate.RedissonRegionFactory
hibernate.cache.use_query_cache=true
hibernate.cache.use_second_level_cache=true
hibernate.cache.redisson.fallback=true
hibernate.cache.redisson.config=redisson.yaml
jc3wubiy

jc3wubiy1#

是的,是的。这就是模块的目的。
第一个容器中的java应用程序看不到记录的更新
您可能连接到同一个redis但不同的数据库。如果定义了此选项。
每个java应用程序都有自己的记录版本。
这在redis是不可能的。
您能描述一下您的应用程序结构和redis设置吗?

相关问题