spring-data-redis

spring data redis master slave config

心不动则不痛 提交于 2019-12-22 09:46:31
问题 Following is my jedis config @Bean public JedisConnectionFactory getJedisConnectionFactory() { JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(); jedisConnectionFactory.setUsePool(true); return jedisConnectionFactory; } @Bean public RedisTemplate<String, Object> getRedisTemplate() { RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>(); redisTemplate.setConnectionFactory(getJedisConnectionFactory()); return redisTemplate; } This config

Spring Session Data Redis - Get Valid Sessions, Current User from Redis Store

耗尽温柔 提交于 2019-12-22 03:51:31
问题 My question is, in distributed web application is it possible to get the valid sessions from Redis Store using RedisOperationSessionRepository . (I mean I don't want to write explicit code for putting it into Redis store and then later read it, I want to understand if framework or spring-data-redis library provides that). I am aware that Spring Redis is able to restore sessions and server restarts also preserve the login if the session is still valid (as it is backed by Redis) One of the

Field error in object 'target' on field '': rejected value []; codes [typeMismatch.target.,typeMismatch.,typeMismatch.java.util.Date,typeMismatch]

你离开我真会死。 提交于 2019-12-22 00:02:43
问题 I've created: https://jira.spring.io/browse/BATCH-2778 I am developing Spring Batch + Redis (Spring Data Redis) example. In this example, I'm reading student.csv file and storing all the data as is in Redis DB. I wanted to used dateOfBirth as Date and I am sure that I need to do some date logic conversion to store value Date in Redis . As per my analysis, it looks like I wont be able to use @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") , because I am not dealing with

INFO warnings about multiple modules in Spring Boot, what do they mean?

≡放荡痞女 提交于 2019-12-21 06:47:30
问题 I recently bumped up my spring boot version to 1.4.0. Now I see the following warnings below. I am using spring-mongodb and spring-redis (strictly for caching). Is this something I should be concerned about? Multiple Spring Data modules found, entering strict repository configuration mode! Spring Data Redis - Could not safely identify store assignment for repository What does strict repository configuration mode really mean? . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '

Spring RedisConnectionFactory with transaction not returning connection to Pool and then blocks when exhausted

╄→гoц情女王★ 提交于 2019-12-20 12:09:49
问题 My configuration for creating the connection factory with with a connection pool. I do have a connection pool. Most of this code is copied from Spring's RedisAutoConfiguration which I have disabled for particular reasons. @Configuration @EnableConfigurationProperties(RedisProperties.class) public class JedisConfiguration implements RedisConfiguration { @Bean @Scope("prototype") @Override public RedisConnectionFactory connectionFactory(RedisProperties redisProperties) { return createFactory

spring-data-redis redisTemplate Exception

青春壹個敷衍的年華 提交于 2019-12-20 01:09:19
问题 When I call get() method, an exception occured here is the code @Service("RedisService") public class RedisServiceImpl implements RedisService { @Autowired RedisTemplate<String, Long> redisTemplate; @Override public Long get(String key) { return redisTemplate.opsForValue().get(key); } @Override public Long incrBy(String key, long increment) { return redisTemplate.opsForValue().increment(key, increment); } when I use incrBy method, there are no exceptions but only errors only get method here

How to get same rank for same scores in Redis' ZRANK?

雨燕双飞 提交于 2019-12-19 21:35:49
问题 If I have 5 members with scores as follows a - 1 b - 2 c - 3 d - 3 e - 5 ZRANK of c returns 2, ZRANK of d returns 3 Is there a way to get same rank for same scores? Example: ZRANK c = 2, d = 2, e = 3 If yes, then how to implement that in spring-data-redis? 回答1: Any real solution needs to fit the requirements, which are kind of missing in the original question. My 1st answer had assumed a small dataset, but this approach does not scale as dense ranking is done (e.g. via Lua) in O(N) at least.

How to model Data in Redis for values Complex Data structure?

隐身守侯 提交于 2019-12-19 09:45:25
问题 I've taken a reference of the link : http://panuoksala.blogspot.com/2015/09/redis-many-to-many.html to developed below code. I've implemented some code, looks like nothing is achievable so far as Get User 1 groups: hget User:1 Groups Does not yeild the results. I wanted to get answer more from the Data Modelling perspectives. I've modeled code like below, but its not working as per my requirement - Group.java @Builder @Data @AllArgsConstructor @NoArgsConstructor @RedisHash("groups") public

set expire key at specific time when using Spring caching with Redis

萝らか妹 提交于 2019-12-12 12:18:28
问题 I am spring caching abstraction annotations to apply caching to my service methods. Since I am using Redis as the cache store, I want to use the option of expiring cache at a specific time, since that is supported by Redis. expireat command in redis can be used to set expire time at a future time. I am not sure how I can do that for the keys which are part of my cache when using RedisCache. I tried to customize RedisCacheManager by creating a bean of it. I see there is a getNativeCache()

ERR EXEC without MULTI - spring redis+jedis

送分小仙女□ 提交于 2019-12-12 02:04:55
问题 I meet with exception during a transactional operation with spring-data-redis RedisTemplate<String,Object> cartCache; public void create(final Cartline cartline) { Object txResults = cartCache.execute(new SessionCallback<List>() { public List execute(RedisOperations operations) throws DataAccessException { String cartId = cartline.getMemberId(); String cartlineId = cartline.getCartlineId(); operations.multi(); ...... return operations.exec(); } }); } redis.clients.jedis.exceptions