jedis

Spring Redis Error Handle

别等时光非礼了梦想. 提交于 2019-12-13 11:33:00
问题 I am using Spring + Redis as my cache component in the new project. The spring config xml file is: <!-- Jedis Connection --> <bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" p:host-name="${redis.ip}" p:port="${redis.port}" p:use-pool="${redis.use-pool}" /> <!-- Redis Template --> <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate"> <property name="connectionFactory" ref="jedisConnectionFactory" />

Can you expire a key value pair for a hashKey in Redis

旧城冷巷雨未停 提交于 2019-12-13 07:43:20
问题 I want to expire a particular key/value pair set in a hashKey in redis. But redis expires the whole hashKey with all keyValue pairs inside lost. For example i just want to remove Key:666 from seqNu. Using jedis.setex is other option but u cant set a hashKey in it. jedis.hset("seqNu","666",System.currentTimeMillis()+""); jedis.hset("seqNu","777",System.currentTimeMillis()+""); jedis.expire("seqNu", 20); // This expires the whole HashKey: seqNu after 20 seconds 回答1: Redis only expires "whole"

Access ElasticCache - Jedis and spring

限于喜欢 提交于 2019-12-13 07:39:22
问题 We are just starting on AWS and have requirement to use AWS ElasticCache with Redis-jedis with Spring. Spring-data-redis 1.8.8.RELEASE aws-java-sdk 1.11.228 Spring 4.2.9.RELEASE jedis 2.9.0 I was able to connect and cache data to local redis with below code. I have tried making code changes as https://github.com/fishercoder1534/AmazonElastiCacheExample/tree/master/src/main/java , but not been successful. Would really appreciate some guidance and help with some sample code. AWS ElasticCache is

sbt compile fails due to missing constructor Jedis(java.net.URI) in Jedis 2.1.0

∥☆過路亽.° 提交于 2019-12-13 05:09:25
问题 My simple project has a library dependency on Jedis (the Java Redis library): name := "fit001" version := "1.0-SNAPSHOT" libraryDependencies ++= Seq( javaJdbc, javaEbean, cache, "redis.clients" % "jedis" % "2.1.0" ) play.Project.playJavaSettings I ran both play update and play dependencies successfully. Here are the resolved dependencies of your application: +-------------------------------------------------------------------+--------------------------------------------------------+----------

Subscribe to multiple channels with same thread Jedis

最后都变了- 提交于 2019-12-12 21:02:56
问题 I have an application that uses Redis publish/subscribe to transfer messages between clients using the Jedis client in Java. I want to be able to subscribe to channels at runtime when the user types a command but as subscribe is a blocking operation as it listens on the thread that calls subscribe I'm not sure how to go about subscribing to other channels at a later date on the original thread. Example: private PubSubListener psl = new PubSubListener(); public void onCommand(String[] args) {

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

JedisCluster : Scan For Key does not work

天涯浪子 提交于 2019-12-11 16:24:13
问题 I was trying to scan for particular key stored in JedisCluster. String product = "MMATest"; String redisServer = "mycachecluster.eaogs8.0001.usw2.cache.amazonaws.com:6379,mycachecluster.eaogs8.0002.usw2.cache.amazonaws.com:6379"; Set<HostAndPort> jedisClusterNode = new HashSet<>(); String[] serversArray = redisServer.split(";"); for (String aServersArray : serversArray) { jedisClusterNode.add(new HostAndPort(aServersArray.split(":")[0], Integer.valueOf(aServersArray.split(":")[1]))); }

Not able to connect to redis server from docker container

牧云@^-^@ 提交于 2019-12-11 13:43:25
问题 My docker version is 1.13.1. I am trying to connect to redis-server from my docker container,but I am getting connection refused error.Detailed logs are given below: Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused at redis.clients.jedis.Connection.connect(Connection.java:207) [jedis-2.9.0.jar:] at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:93) [jedis-2.9.0.jar:] at redis.clients.jedis.BinaryJedis.connect

Why Redis keys are not expiring?

雨燕双飞 提交于 2019-12-11 04:12:50
问题 I have checked these questions but they did not help me to fix my issue. I am using Redis as a key value store for Rate Limiting in my Spring REST application using spring-data-redis library. I test with huge load. In that I use the following code to store a key and I am setting the expire time as well. Most of the time the key expires as expected. But some times the key is not expiring! code snippet RedisAtomicInteger counter = counter = new RedisAtomicInteger("mykey"); counter.expire(1,

String hostname from properties file: Java

拟墨画扇 提交于 2019-12-11 03:05:46
问题 This may sound like a really simple problem but I can't figure out a way around this. I have a config.properties file which contains two key values: an IP address and a Port number. I read this config file to extract the key values in string format. However, when I am trying to use these values, I am unable to connect to the IP address retrieved from the config file. The reason is that the values read are in string format and I need to convert them to proper formats before using them. What I