hibernate-redis icon indicating copy to clipboard operation
hibernate-redis copied to clipboard

Hibernate does not read entities from cache

Open Marek00Malik opened this issue 6 years ago • 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 !

Marek00Malik avatar Feb 21 '18 11:02 Marek00Malik

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

Marek00Malik avatar Feb 21 '18 11:02 Marek00Malik

Anyone can help ?

Marek00Malik avatar Mar 08 '18 14:03 Marek00Malik

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

debop avatar Apr 03 '18 13:04 debop

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.

PrakashHadgal avatar Oct 22 '19 06:10 PrakashHadgal