spring-data-redis

spring-boot-starter-data-redis Cacheable(sync=true) sees not work?

送分小仙女□ 提交于 2019-12-06 15:48:23
i want to use Cacheable(sync=true) to controll concurrent behaviors to access a method @Service @CacheConfig(cacheNames = "book") public class BookService { @Cacheable(key = "#isbn",sync = true) public Book book(String isbn,int id) { System.out.println("wait 3s..."); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } return new Book(isbn, "xxxx"); } } write a test case: ExecutorService executorService = Executors.newFixedThreadPool(10); for (int i = 0; i < 100; i++) { final int index = i; executorService.execute(new Runnable() { @Override public void run() {

Connections to multiple Redis servers with Spring Data Redis

蓝咒 提交于 2019-12-06 11:33:37
问题 I'm working on an application(Spring) with the following requirements: Read data from Redis Server1 Read data from Redis Server2 Read data from Redis Server3 AND Save the information to MySQL. Can someone give us a thought to connect to different Redis servers using Spring Data Redis. Got a link: http://forum.spring.io/forum/spring-projects/data/nosql/104599-how-to-connect-to-multiple-redis-instances-using-redistemplate?view=stream But that's too old. Any help would be appreciated. 回答1: There

How to build dynamic queries with Spring Data Redis Repositories?

拟墨画扇 提交于 2019-12-06 07:43:27
问题 I'm testing Redis with spring-data-redis using repositories like this: public interface CreditCardRepository extends CrudRepository<CreditCard, String>{ List<CreditCard> findByIssuer(String issuer); List<CreditCard> findByCreditNetwork(String creditNetwork); List<CreditCard> findByCreditNetworkAndIssuer(String creditNetwork, String issuer); } Above methods will query over Redis structures like: creditcard:creditNetwork:mastercard creditcard:creditNetwork:visa creditcard:issuer:company1

Cannot get Jedis connection; Could not get a resource from the pool

橙三吉。 提交于 2019-12-06 06:06:10
问题 I am running a batch job for every 5 minutes and I don't wanna other nodes to run the same job hence I am using Jedis lock to lock an object for 5 minutes. So that other node won't get the lock if they try to run the same job. Job started after acquiring the lock and when I try to read it from Redis I am getting the following exception saying 'Caused by: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool at redis.clients.util.Pool.getResource(Pool

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type to type [java.lang.String] - Redis

ぃ、小莉子 提交于 2019-12-06 05:22:42
I am using Spring Data Redis with the Spring Boot 2.0 example. In this example, I am trying to save the Customer data + Student data together. I'm not very sure how the data modelling happens here, but assuming its same like as Mongo DB (pure non relational). Could someone please help with the below error ? As its clear that some conversion has been expected to see the data. Error: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [com.javasampleapproach.redis.model.Customer] to type [java.lang.String] at org.springframework.core

Spring-data-redis @Cacheable java.lang.ClassCastException: java.util.HashMap cannot be cast to java.lang.String

帅比萌擦擦* 提交于 2019-12-06 04:22:09
问题 I want to use spring-data-redis to caching data in my spring boot app.But it always says cast exception.I googled for some time but have no ideas.Please help me.thanks,any suggestions are greateful! Here is my RedisConfiguation: @Configuration @EnableCaching public class RedisConfiguration extends CachingConfigurerSupport { @Value("${spring.redis.host}") private String host; @Value("${spring.redis.port}") private String port; @Value("${spring.redis.expire}") private String expire; @Value("$

Redis Hash Pagination

最后都变了- 提交于 2019-12-06 03:08:15
I am using the Redis Hash , in which I am storing student id as the key (which is not numeric), the value is POJO of student data. now I need redis-pagination i.e. I don't care about the students' order but I want to fetch only some students data in one go. can I do this in Redis? if for supporting the pagination some modification in the data structure is required that would be ok too. P.S. I am using spring-data-redis . but the solution without it would be ok too. basically, I want to find out whether redis supports pagination for hashes. Sounds like you are looking for the HSCAN command,

Whether LettuceConnectionFactory have version restrictions on redis and springboot?

落爺英雄遲暮 提交于 2019-12-05 22:03:03
The project need a custom RedisConnectionFactory and finds a problem: when using LettuceConnectionFactory , the runtime always reports java.lang.NullPointerException, while JedisConnectionFactory can pass tests. I think that whether LettuceConnectionFactory have version restrictions on redis and springboot? Developing environment: Springboot: 2.1.0.release redis:3.2.8 jdk8. Java Code @Component @Configuration public class RedisConfig { public LettuceConnectionFactory lettuceConnectionFactoryTest(){ return new LettuceConnectionFactory(new RedisStandaloneConfiguration("127.0.0.1", 6379)); }

Redis - How the key HASH and SET and ZSET are related on the CrudRepository save?

一曲冷凌霜 提交于 2019-12-04 20:55:18
I am new to Redis and developing code using Spring Boot + Spring Data Redis example. When I saved the records, I see KEYS gets created and out of these keys 4 are HASH , 1 ZSET and all others are SET . I did not see in the Spring docs, meaning of each KEY is getting saved. . 127.0.0.1:6379> KEYS * 1) "persons:c5cfd49d-6688-4b83-a9b7-be55dd1c36ad" 2) "persons:firstname:bran" 3) "persons:39e14dae-fa23-4935-948f-1922d668d1c2" 4) "persons:f0b6dd26-8922-4a36-bd2a-792a17dddff7" 5) "persons:address.city:Achalpur" 6) "persons:e493385a-64ae-42be-8398-51757153d273:idx" 7) "persons:053cdfea-e430-4e1c

Connections to multiple Redis servers with Spring Data Redis

二次信任 提交于 2019-12-04 17:40:09
I'm working on an application(Spring) with the following requirements: Read data from Redis Server1 Read data from Redis Server2 Read data from Redis Server3 AND Save the information to MySQL. Can someone give us a thought to connect to different Redis servers using Spring Data Redis. Got a link: http://forum.spring.io/forum/spring-projects/data/nosql/104599-how-to-connect-to-multiple-redis-instances-using-redistemplate?view=stream But that's too old. Any help would be appreciated. There's not out-of-the-box support for accessing multiple servers at once but you can get there yourself. Usually