debop/hibernate-redis

Hibernate does not read entities from cache

Marek00Malik opened this issue · 4 comments

Hi,
I have weird problem with my reds client, meaning hibernate always returns the entity from the db rather then from the cache.

I can see redis containing the searching keys, I even set the expireInSecond to 360000, but with no luck.

My configs:

rdsProperties.put(Environment.USE_MINIMAL_PUTS, properties.getProperty("rds_use_l2cache_minimal_puts"));  // -> true
rdsProperties.put(Environment.GENERATE_STATISTICS, "true");
rdsProperties.put(Environment.CACHE_REGION_PREFIX, "hibernate");
rdsProperties.put(Environment.USE_STRUCTURED_CACHE, "true");
rdsProperties.put(Environment.CACHE_REGION_FACTORY, properties.getProperty("rds_cache_region_factory"));
rdsProperties.put(Environment.CACHE_PROVIDER_CONFIG, properties.getProperty("rds_cache_provider_config_file"));
rdsProperties.put(Environment.USE_SECOND_LEVEL_CACHE, properties.getProperty("rds_use_l2cache"));   // -> true
rds_cache_region_factory=org.hibernate.cache.redis.hibernate52.SingletonRedisRegionFactory
rds_cache_provider_config_file=classpath:./redis-config/hibernate-redis_dev.properties

hibernate-redis_dev.properties:

#
redisson-config=classpath:./redis-config/redission-dev.yaml
#
# Cache Expiry settings
# 'hibernate' is second cache prefix
# 'common', 'account' is actual region name
#
# default = 120 seconds (2 minutes) (see RedisCacheUtil.DEFAULT_EXPIRY_IN_SECONDS)
#
redis.expiryInSeconds.default= 360000
redis.expiryInSeconds.hibernate.common=360000
redis.expiryInSeconds.hibernate.user_permission_map= 360000

redisson configuration

singleServerConfig:
  idleConnectionTimeout: 10000
  pingTimeout: 1000
  connectTimeout: 1000
  timeout: 1000
  retryAttempts: 1
  retryInterval: 1000
  reconnectionTimeout: 3000
  failedAttempts: 1
  password: null
  subscriptionsPerConnection: 5
  clientName: null
  address: "redis://127.0.0.1:6379"
  subscriptionConnectionMinimumIdleSize: 1
  subscriptionConnectionPoolSize: 25
  connectionMinimumIdleSize: 5
  connectionPoolSize: 100
  database: 0
  dnsMonitoring: false
  dnsMonitoringInterval: 5000
threads: 0
# Codec
codec: !<org.redisson.codec.SnappyCodec> {}
useLinuxNativeEpoll: false
eventLoopGroup: null

Thanks for any help !

I'm running Hibernate 5.2 final and hibernate-reds 2.4.0

Anyone can help ?

debop commented

Can you check redis monitor ?
Maybe fail to put entity to redis ...
Any log?

I am using Redis as Second level cache in hibernate. But not able to do that. please any one give me sample project on this.