spring-data-redis

Spring data redis, multi-threading issue with Jedis

放肆的年华 提交于 2021-02-20 03:45:46
问题 I am using redis in a heavily multi-threaded java application and getting intermittent ClassCastException s. Reading through various discussions seemed to point out this might be because the Jedis connection instance getting shared between multiple threads (https://github.com/xetorthio/jedis/issues/359). The solution suggested is to use JedisPool which is thread-safe. I have configured redis through Spring redis support by using RedisTemplate. A thing to note is I am using multiple templates

How can I prefix cacheNames with spring.cache.redis.key-prefix?

限于喜欢 提交于 2021-01-29 11:00:47
问题 I managed to make the cacheNames work and my Redis keys look like this. {cacheName}::{myKey} {cacheName}::{myKey} Now I wonder how can I prefix the {cacheName} part with my configured value of spring.cache.redis.key-prefix ? When I put these entries, spring.cache.redis.key-prefix=some:: spring.cache.redis.use-key-prefix=true I want the keys look like this. some::{cacheName}::{myKey} some::{cacheName}::{myKey} 回答1: I'm not sure of the way of using configuration along with internal

RedisSystemException: java.lang.ClassCastException: [B cannot be cast to java.lang.Long

不问归期 提交于 2021-01-28 03:05:40
问题 I meet this exception when using jedis with spring-data-redis in multi threading environment: org.springframework.data.redis.RedisSystemException: Unknown redis exception; nested exception is java.lang.ClassCastException: [B cannot be cast to java.lang.Long at org.springframework.data.redis.FallbackExceptionTranslationStrategy.getFallback(FallbackExceptionTranslationStrategy.java:48) at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate

RedisSystemException: java.lang.ClassCastException: [B cannot be cast to java.lang.Long

孤人 提交于 2021-01-28 00:33:28
问题 I meet this exception when using jedis with spring-data-redis in multi threading environment: org.springframework.data.redis.RedisSystemException: Unknown redis exception; nested exception is java.lang.ClassCastException: [B cannot be cast to java.lang.Long at org.springframework.data.redis.FallbackExceptionTranslationStrategy.getFallback(FallbackExceptionTranslationStrategy.java:48) at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate

How to implement multitenancy for redis in spring boot

落爺英雄遲暮 提交于 2021-01-01 10:04:38
问题 I am working on making my whole application multi-tenanted but stuck on redis. So far I created a map of JedisConnectionFactory and tried to pass it to RedisTemplate but it throwing java.lang.IllegalArgumentException: template not initialized; call afterPropertiesSet() before using it. Below are code snippets: @Component public class RedisConfiguration { @Autowired private DSConfig dsConfig; private Map<String,JedisConnectionFactory> jedisConnectionFactoryMap = new HashMap<>(); private static

How to implement multitenancy for redis in spring boot

馋奶兔 提交于 2021-01-01 10:04:32
问题 I am working on making my whole application multi-tenanted but stuck on redis. So far I created a map of JedisConnectionFactory and tried to pass it to RedisTemplate but it throwing java.lang.IllegalArgumentException: template not initialized; call afterPropertiesSet() before using it. Below are code snippets: @Component public class RedisConfiguration { @Autowired private DSConfig dsConfig; private Map<String,JedisConnectionFactory> jedisConnectionFactoryMap = new HashMap<>(); private static

Filter based on Integer Comparison in Spring data redis

倾然丶 夕夏残阳落幕 提交于 2020-12-15 05:24:15
问题 I am using spring-data-redis to communicate with database. I have entity class like below @RedisHash(value = "employee") public class Employee { @Id private long id; @Indexed private String name; @Indexed private int age; private Address address; ...... ...... ...... } I want to filter the employees based on age group. For example, age lesser than 35 (age<35). How to achieve this in below repository? @Repository public interface EmployeeRepo extends CrudRepository<Employee, Long> { public

Filter based on Integer Comparison in Spring data redis

和自甴很熟 提交于 2020-12-15 05:24:05
问题 I am using spring-data-redis to communicate with database. I have entity class like below @RedisHash(value = "employee") public class Employee { @Id private long id; @Indexed private String name; @Indexed private int age; private Address address; ...... ...... ...... } I want to filter the employees based on age group. For example, age lesser than 35 (age<35). How to achieve this in below repository? @Repository public interface EmployeeRepo extends CrudRepository<Employee, Long> { public