jedis
A blazingly small and sane redis java client
Normally, I get the key set then use a look to delete each key/value pair.
Is it possible to just delete all keys via pattern?
ie:
Del sample_pattern:*
Source: (StackOverflow)
I've started using Redis in my project with the help of the Jedis library. All is working fine but now I have a problem that my functional tests requires Redis to be up which I want to avoid in my Continuous Integration. What is the best way to do this?
Source: (StackOverflow)
In a simple situation with 3 servers with 1 master and 2 slaves with no sharding. Is there a proven solution with java and Jedis that has no single point of failure and will automatically deal with a single server going down be that master or slave(automated failover). e.g. promoting masters and reseting after the failure without any lost data.
It seems to me like it should be a solved problem but I can't find any code on it just high level descriptions of possible ways to do it.
Who actually has this covered and working in production?
Source: (StackOverflow)
I am using Spring Data Redis with Jedis. I am trying to store a hash with key vc:${list_id}
. I was able to successfully insert to redis. However when I inspect the keys via redis-cli, I don't see the key vc:501381
. Instead I see \xac\xed\x00\x05t\x00\tvc:501381
. Why is this happening and how do I change this?
Source: (StackOverflow)
I'm using Jedis as the java client to connect to Redis Servers.
Question 1: It seems there is no method to get/set Object < ? extends Serializable> ? All the values must be String or byte[]?
Other clients like "JRedis" and Spymemcache(for memcached Server) could.
Question 2: If I use ShardedJedis, it cannot set auth/password? While Jedis class can (using auth(String password)).
Source: (StackOverflow)
I am looking around redis to provide me an intermediate cache storage with a lot of computation around set operations like intersection and union.
I have looked at the redis website, and found that the redis is not designed for a multi-core CPU. My question is, Why is it so ?
Also, if yes, how can we make 100% utilization of CPU resources with redis on a multi core CPU's.
Source: (StackOverflow)
I am trying to implement a expiry key notification with redis ,when my key expires in the redis data store. The redis website provides some description of how http://redis.io/topics/notifications, but Im unable to find any example how to do it using redis java client like Jedis?
Any possible code with illustration will be very helpful as im new to redis.
Source: (StackOverflow)
I am getting mixed answers on my research here.
Can someone verify that the Redis Server can only store representation of any numerical values?
For instance, if I use a Java client (Jedis) with a double type in lpush, do I need to convert it to the equivalent of a string type before sending to Redis?
Or is there a way to I can send over an actual numeric type like a double? If so, is there any example code on how to accomplish this?
Thanks
Source: (StackOverflow)
I have to start working on Redis and jedis.
I am completely new to this and just now starting with it.
I am reading and trying to understand what it is.
Can any one help me in knowing what all do i need to download/install and start working on redis/jedis.
I will really appreciate a lof if any one can help me out for understanding how to start/work with redis
Thanks,
Yogesh Chaudhari
Source: (StackOverflow)
I am pretty new to Redis.
I downloaded Jedis and added that to my classpath. But, it doesnt provide a way to store java object as "value"
Am i missing something or Jedis doesn't provide the way to store java object as value?
Thanks,
-Venkat
Source: (StackOverflow)
I'm facing a very strange issue : i get really crappy writing speeds when using redis (in a ideal world the writing speed should be approaching the writing speed on RAM).
Here is my benchmark :
package redisbenchmark;
import redis.clients.jedis.Jedis;
public class RedisBenchmark {
private static final String REDIS_KEY = "anon_id";
private Jedis conn;
private long writeTimeNano=0;
private RandomString stringGenerator;
private String[] fields;
public RedisBenchmark(){
conn = new Jedis("localhost");
stringGenerator = new RandomString(32);
}
public void run(int nbWrites, int nbReads){
writeBenchmark(nbWrites);
}
public void writeBenchmark(int amount){
fields = new String[amount];
for(int i=0; i< amount; i++){
fields[i] = stringGenerator.nextString();
}
long start = System.nanoTime();
for(int i=0; i< amount; i++){
write(fields[i]);
}
writeTimeNano+=System.nanoTime()-start;
double seconds = (double)writeTimeNano / 1000000000.0;
System.out.println("[write]nb:"+amount+"|time:"+seconds+"|speed:"+((amount*33)/(seconds*1024*1024))+" MB/s");
}
public void write(String anonId){
conn.hsetnx(REDIS_KEY, anonId, "1");
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
RedisBenchmark benchmark = new RedisBenchmark();
benchmark.run(100000, 200);
}
}
RandomString
is a class that generates a random string (the arg is the string length)
And below are a couple of results :
[write]nb:100000|time:4.408319378|speed:0.713905907055318 MB/s
[write]nb:100000|time:4.447246995|speed:0.707656949946542 MB/s
I tried to modify the save to hdd parameters in the config file but with no improvement.
I have 2 ideas:
1. Its a socket problem since client and server (redis) are on the same machine
2. The connector implementation has performance issues
UPDATE The benchmark results for set operation:
====== SET ======
10000 requests completed in 0.09 seconds
50 parallel clients
3 bytes payload
keep alive: 1
99.51% <= 1 milliseconds
100.00% <= 1 milliseconds
111111.11 requests per second
System specification :
- Ubuntu 11.04
- 8GB RAM
- Intel i5 processor
Any suggestion will be greatly appreciated.
Source: (StackOverflow)
I'm using redis and spring framework on my image upload server. I need to store the images to redis. I have found the following question but it was for python.
how to store a image into redis using python / PIL
I'm not sure if it's the best way but I would like to know how to do it in java (preferably using spring framework). I'm using spring-data-redis which uses jedis.
I would like to know if it is a good strategy to store images in redis.
Source: (StackOverflow)
redis:
redis>zadd zsetA 1 'A'
redis>zadd zsetA 2 'B'
redis>zadd zsetA 3 'C'
redis>zadd zsetA 5 'E'
redis>zadd zsetB 1 'A'
redis>zadd zsetB 2 'B'
redis>zadd zsetB 3 'C'
redis>zadd zsetB 4 'D'
opearate:
a=redis.ZRANGEBYSCORE 'zsetA',1,3
b=redis.ZRANGEBYSCORE 'zsetB',2,4
result=a∩b
how to quick get 'result' in sigle command?
Source: (StackOverflow)
I have a news site that have a lot of topics. There might be millions of users following topics.
I maintain a sortedset for each user to load news belonging to topics they are following. When an article is added or updated, I will write this article to affected users' lists.
Specifically, pseudo code as follows:
if a article is added/updated
get all topics that the article belong (each article may belong to many topics)
for each topic: get all topic followers
update_user_news_list(userId, articleId)
This is the java code with jedis:
static final int LIMIT_BATCH = 1000;
static void addToUserHomeFeed(int index, Jedis jd) {
int range_limit = index + LIMIT_BATCH - 1;
Set<String> list = jd.zrange("Follower:Topic:Id", index, range_limit); // get list of followers
if (list.isEmpty()) return;
Iterator<String> it = list.iterator();
while (it.hasNext()) {
// update user list
}
addToUserHomeFeed(range_limit + 1, jd);
}
The problem is, my site currently has nearly 1 million users, some popular topics followed by around 800000 users and sometimes the system produces "buffer overflow" errors.
Am I doing something wrong or there are better approaches?
I use redis 2.4
Source: (StackOverflow)
I am using RedisTemplate to get and store data as a list.
When I am storing data - I store it as
redisTemplate.opsForList().rightPush("key1", "value11");
redisTemplate.opsForList().rightPush("key1", "value12");
redisTemplate.opsForList().rightPush("key2", "value21");
redisTemplate.opsForList().rightPush("key2", "value22");
Now I want to get the list values for both the keys in one single call
I can get individually by
redisTemplate.opsForList().range("key1", 0, -1);
redisTemplate.opsForList().range("key2", 0, -1);
But is there a way to use multi get with list. If the values are of type string, I am able to use multisite, but I dont see any api with list.
Source: (StackOverflow)