Giter VIP home page Giter VIP logo

jedis's Introduction

Jedis

Release Maven Central Javadocs MIT licensed Integration codecov Discord

What is Jedis?

Jedis is a Java client for Redis designed for performance and ease of use.

Are you looking for a high-level library to handle object mapping? See redis-om-spring!

How do I Redis?

Learn for free at Redis University

Build faster with the Redis Launchpad

Try the Redis Cloud

Dive in developer tutorials

Join the Redis community

Work at Redis

Supported Redis versions

The most recent version of this library supports redis version 5.0, 6.0, 6.2, 7.0 and 7.2.

The table below highlights version compatibility of the most-recent library versions and Redis versions. Compatibility means communication features, and Redis command capabilities.

Jedis version Supported Redis versions JDK Compatibility
3.9+ 5.0 and 6.2 Family of releases 8, 11
>= 4.0 Version 5.0 to current 8, 11, 17
>= 5.0 Version 6.0 to current 8, 11, 17

Getting started

To get started with Jedis, first add it as a dependency in your Java project. If you're using Maven, that looks like this:

<dependency>
    <groupId>redis.clients</groupId>
    <artifactId>jedis</artifactId>
    <version>5.0.0</version>
</dependency>

To use the cutting-edge Jedis, check here.

Next, you'll need to connect to Redis. Consider installing a redis-stack docker:

docker run -p 6379:6379 -it redis/redis-stack:latest

For many applications, it's best to use a connection pool. You can instantiate a Jedis connection pool like so:

JedisPool pool = new JedisPool("localhost", 6379);

With a JedisPool instance, you can use a try-with-resources block to get a connection and run Redis commands.

Here's how to run a single SET command within a try-with-resources block:

try (Jedis jedis = pool.getResource()) {
  jedis.set("clientName", "Jedis");
}

Jedis instances implement most Redis commands. See the Jedis Javadocs for the complete list of supported commands.

Easier way of using connection pool

Using a try-with-resources block for each command may be cumbersome, so you may consider using JedisPooled.

JedisPooled jedis = new JedisPooled("localhost", 6379);

Now you can send commands like sending from Jedis.

jedis.sadd("planets", "Venus");

Connecting to a Redis cluster

Jedis lets you connect to Redis Clusters, supporting the Redis Cluster Specification. To do this, you'll need to connect using JedisCluster. See the example below:

Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7379));
jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7380));
JedisCluster jedis = new JedisCluster(jedisClusterNodes);

Now you can use the JedisCluster instance and send commands like you would with a standard pooled connection:

jedis.sadd("planets", "Mars");

Using Redis modules

Jedis includes support for Redis modules such as RedisJSON and RediSearch.

See the RedisJSON Jedis or RediSearch Jedis for details.

Failover

Jedis supports retry and failover for your Redis deployments. This is useful when:

  1. You have more than one Redis deployment. This might include two independent Redis servers or two or more Redis databases replicated across multiple active-active Redis Enterprise clusters.
  2. You want your application to connect to one deployment at a time and to fail over to the next available deployment if the first deployment becomes unavailable.

For the complete failover configuration options and examples, see the Jedis failover docs.

Documentation

The Jedis wiki contains several useful articles for using Jedis.

You can also check the latest Jedis Javadocs.

Some specific use-case examples can be found in redis.clients.jedis.examples package of the test source codes.

Troubleshooting

If you run into trouble or have any questions, we're here to help!

Hit us up on the Redis Discord Server or Jedis GitHub Discussions or Jedis mailing list.

Contributing

We'd love your contributions!

Bug reports are always welcome! You can open a bug report on GitHub.

You can also contribute documentation -- or anything to improve Jedis. Please see contribution guideline for more details.

License

Jedis is licensed under the MIT license.

Sponsorship

Redis Logo

jedis's People

Contributors

alextkachman avatar avital-fine avatar avitalfineredis avatar chayim avatar dengliming avatar dependabot[bot] avatar devfozgul avatar dvirdukhan avatar ewhauser avatar gerzse avatar gkorland avatar grdmitro avatar heartsavior avatar ivowiblo avatar kevinsawicki avatar marcosnils avatar mardambey avatar mayankdang avatar mindwind avatar nrodrigues avatar nykolaslima avatar phufool avatar raszi avatar samhendley avatar sazzad16 avatar taer avatar xetorthio avatar yangbodong22011 avatar yaourt avatar zeekling avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jedis's Issues

tests documentation

Hi,

I apologise if I'm missing something obvious, but my tests are failing.

Do I need to start my own redis instance? Presumably I have to start it with the configs found in "conf", but it fails with:

redis-server conf/redis.conf

*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 216
>>> 'no-appendfsync-on-rewrite no'
Bad directive or wrong number of arguments

I'm using redis 2.0.2 (via macports)

Thanks,
Juan

Murmur hashing fails with more than 2 shards

I have a ShardedJedisPool configured to use Murmur Hashing.
If I use it with two shards it splits the keys evenly among them.
If I add a third shard the first shard gets around 25% of they keys, the second one around 75% and the third one none.

ClassCastException: Integer cannot be cast to String

I'm happy to submit copies of whatever code you'd like, but I'm fairly convinced this is a Jedis issue and not an issue with my setup. The two classes listed are here, http://paste.ly/x7L . I don't see any issues with my redis server at the moment. At the same time as I receive this stack trace, I can use redis-cli to get keys successfully.

    java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:121)
at redis.clients.jedis.Jedis.setex(Jedis.java:442)
at com.tedpennings.blog.cache.redis.RedisCacheRepository.cacheString(RedisCacheRepository.java:89)
at com.tedpennings.blog.foursquare.FoursquareLocationProvider.getLocation(FoursquareLocationProvider.java:44)
at com.tedpennings.blog.foursquare.FoursquareLocationProvider.getLocation(FoursquareLocationProvider.java:62)
at com.tedpennings.blog.controllers.BaseController.getFoursquareLocation(BaseController.java:104)
at sun.reflect.GeneratedMethodAccessor33.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:162)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:427)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:327)
at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:126)
at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:195)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:159)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:417)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

automaticall return Jedis instances to the pool when closed

Would it be possible to automatically return Jedis instances to the pool when they are 'closed' (disconnected/quit)? Currently one needs to keep track of the connection usage if JedisPool is used which makes it hard to properly do cleanup.
It's a lot easier and consistent to simply ask the client to work with a Jedis instance (no matter if JedisPool is used or not).

Jedis incr returns Integer instead of Long

I noticed that Jedis's (v1.4.0) 'incr' implementation returns a java.lang.Integer, instead of a java.lang.Long. Since redis's incr is a 64-bit signed 'integer', I think this should be switched to a Long to not loose bits.

Thanks!

Pipelined HMSET throws ClassCastException

I'm attempting to a do a series HMSET in a pipeline for batch inserts and getting this exception

java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:121)
at redis.clients.jedis.Jedis.hmset(Jedis.java:728)

The commands I'm executing are as follows:

+1289381390.666655 "HMSET" "grails.gorm.tests.Person:1" "lastName" "Builder" "firstName" "Bob"
+1289381390.670692 "SADD" "grails.gorm.tests.Person.all" "1"
+1289381391.967739 "HMSET" "grails.gorm.tests.Person:2" "lastName" "Flintstone" "firstName" "Fred"

This issue is preventing me from supporting batch writes (using a pipeline) in GORM for Redis

MurmurHash instead of MD5 as sharding hashing algorithm ...

May I propose to use MurmurHash instead of MD5 for Ketama hash algorithm ?

MD5 avalanche behavior is OK, but under heavy load, it could become slow and / or too consuming ...
MurmurHash is not a crypto hash function, but is really fast and had a very good avalanche behavior.

There is already an open source (public domain) Java implementation here : http://dmy999.com/article/50/murmurhash-2-java-port

General info available here : http://en.wikipedia.org/wiki/MurmurHash

Regards

ArrayIndexOutOfBoundsException when buffer gets full and isn't flushed properly

I got this exception from some tests I was running:

java.lang.ArrayIndexOutOfBoundsException: 8192
at redis.clients.util.RedisOutputStream.write(RedisOutputStream.java:37)
at redis.clients.jedis.Protocol.sendCommand(Protocol.java:24)
at redis.clients.jedis.Connection.sendCommand(Connection.java:60)
at redis.clients.jedis.Jedis.get(Jedis.java:54)

Looking at the code, I'm thinking maybe the Jedis client isn't thread-safe, so there should be one instance per thread?

thanks for any feedback,
-Z

"Unknown reply" exception.

Hello,

I'm using redis 2.1.7 (for compiled for Win64 bit) with jedis 1.4.0.jar file.
I started to randomly get this exception:

Caused by: redis.clients.jedis.JedisException: Unknown reply:  
    at redis.clients.jedis.Protocol.process(Protocol.java:69)
    at redis.clients.jedis.Protocol.read(Protocol.java:120)
    at redis.clients.jedis.Connection.getBinaryBulkReply(Connection.java:162)
    at redis.clients.jedis.Connection.getBulkReply(Connection.java:152)
    at redis.clients.jedis.Jedis.get(Jedis.java:68)
    at com.hexbinama.hdyf.service.impl.PostsServiceJedisImpl.getRecentPosts(PostsServiceJedisImpl.java:75)
    ... 44 more

I've only started to get this exception few minutes ago, and I did change nothing in the jedis service part. The only think that I can think of right now is that the number of keys in the database is over 200 for some minutes.

If I restart the server, it starts to work again, but is now second time that I get it without a reason.

PS: there are two spaces after "Unknown reply: " reported in the console of my IDE.

Using JedisPool, seeing at random a "PONG" as a response to a get

We are using Jedis with JedisPool providing the Jedis connections. In our code, we are rapidly getting Jedis connections from the JedisPool, putting a value into Redis, and releasing this resource back to the JedisPool. We are processing over 100,000 items that need to be stored. With that writting code we have exposed end points that let us read from Redis via the same JedisPool of connections. Occasionally when reading, we will get a response of "PONG" back.
After the reviewing the code, I only see one spot that deals with a Redis "ping", which would bring about a "PONG" response. This code is a thread detailing with the validation and clean-up of Jedis connections.

It seems like server has closed the connection

Hi,

We are using redis in a web application. The Jedis poll is retreived through JNDI. Using Jetty, we have configured it like this:

<New class="org.eclipse.jetty.plus.jndi.Resource">
    <Arg>redis/jaxspot</Arg>
    <Arg>
        <New class="redis.clients.jedis.JedisPool">
            <Arg>
                <New class="org.apache.commons.pool.impl.GenericObjectPool$Config">
                    <Set type="int" name="minIdle">4</Set>
                    <Set type="int" name="maxActive">10</Set>
                </New>
            </Arg>
            <Arg>127.0.0.1</Arg>
            <Arg type="int">6379</Arg>
        </New>
    </Arg>
</New>

So this is basically a pool of 4 to 10 connections. In our application the first requests goes well. But when we wait about 2-3 minutes and we refresh the page, redis crashed. The following code:

Jedis jedis = pool.getResource();
[...]
String v = jedis.get(s);

throws the exception:

Caused by: redis.clients.jedis.JedisException: It seems like server has closed the connection.
at redis.clients.util.RedisInputStream.readLine(RedisInputStream.java:90)
at redis.clients.jedis.Protocol.processBulkReply(Protocol.java:83)
at redis.clients.jedis.Protocol.process(Protocol.java:66)
at redis.clients.jedis.Protocol.read(Protocol.java:121)
at redis.clients.jedis.Connection.getBinaryBulkReply(Connection.java:163)
at redis.clients.jedis.Connection.getBulkReply(Connection.java:153)
at redis.clients.jedis.Jedis.get(Jedis.java:68)
at net.playtouch.jaxspot.module.caching.redis.RedisTransactionalCache$1.execute(RedisTransactionalCache.java:28)

upload artifacts (including javadoc and sources) into Maven central

Hi,
It would be useful to have the versions uploaded into Maven central for easier consumption. The last version 1.4.0 is not there as far as I can see which requires us to create our own copy which is cumbersome.

It would be nice to avoid having to do this in the future.
Thanks

Nice project

Hi!
I'm using Jredis for a long time, but now I need an other one that support connection pool.
I was surprised that this project seem nice, but it's hard to find it on search engine like google.
I think it's good to create your homepage on google code or something like it, some more documents...
thank you for your work.

support for upcoming Redis 2.2

Hi,

As Redis 2.2 is approaching RC phase, it would be nice to get support for the new commands in Jedis. I'll gladly test them (once the windows port completes :) ).

NullPointerException in zscore

Hi, i get NullPointerException in zscore method, when key does not exist in set.
java.lang.NullPointerException
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:991)
at java.lang.Double.valueOf(Double.java:475)
at redis.clients.jedis.Jedis.zscore(Jedis.java:516)

Seems that there is no check for null response in code, or am I missing something?

Thanks

Exclusion operators in ZxxxRANGEBYSCORE

Sorted sets allow you to retrieve ranges with an exclusive rather than inclusive start or end value. These could be optional boolean parameters to the z...rangeByScore() methods.

binary pub/sub support

Hi,

JedisPubSub still uses Strings instead of byte[] without providing a binary equivalent (like BinaryJedis).

Getting Exception while trying to do a jedis.get() command - ClassCastException

I have pasted the Exception that I'm getting below using version 1.5.0. I'm attempting to use the pool to pull jedis objects out of to use:

jedisPool = new JedisPool(new GenericObjectPool.Config(), "cache01");

and here is the thread code that I'm using to check the cache:
http://pastebin.com/icTDwFNH

it happens intermittently but when it does it floods the logs with these error messages. Any ideas?

SEVERE: java.lang.ClassCastException: [B cannot be cast to java.lang.Long ::--> om.mysite.something.getCache updateCache
java.lang.ClassCastException: java.lang.Long cannot be cast to [B
at redis.clients.jedis.Connection.getBinaryBulkReply(Connection.java:163)
at redis.clients.jedis.Connection.getBulkReply(Connection.java:153)
at redis.clients.jedis.Jedis.get(Jedis.java:68)
at com.mysite.something.getCache(Cache.java:19)

isResourceValid failed

Hi!
I'm testing on Redis 2.0 RC4 and it return "PONG" on ping() instead of "OK", so the "isResourceValid" will failed on checking connection properly.

rich exceptions

It would be useful to have rich exceptions, to distinguish between recoverable and unrecoverable errors. I don't have a lot of insight into the 'driver' to pinpoint some examples but from a top-level view, it would be useful to differentiate between:

a. network exception (unrecoverable) - the connection to the db went down
b. protocol exception (recoverable?) - the data request/reply was corrupted/invalid for some reason:

  • incorrect number of arguments - unsupported operation (issuing an illegal command during multi).

The API shields one from doing too many mistakes at the protocol level but I assume there are some corner cases that cannot be prevented. Anyway, having a difference between A and B would be a good start.

API doesn't support byte[]

I'm trying to use this to store serialized objects but the lack of raw byte[] support makes that difficult. Are you planning on support raw byte[]?

JedisPool with one arg constructor fails

When i try to setup a JedisPool with:
JedisPool pool = new JedisPool("localhost", Protocol.DEFAULT_PORT);
the pool will fail to create connection. At least i have to set the port:
JedisPool pool = new JedisPool("localhost", Protocol.DEFAULT_PORT);
So my guess is that the function JedisPool(String host) is not setting the default port.

Jedis preventing application to close

Hi,

We are using Jedis for a very large website. When integrating it, we saw an issue with the way Repair threads are used.

if no Redis daemon is available, the following commands block the shutdown of the application:

jedisPool.init()
jedisPool.destroy();

The destroy thread block at:

repairThreads[i].interrupt();
repairThreads[i].join();

in the destroy method. The cause is that the repair threads never stops and thus the join does not finish.

I saw that the repair threads are not stoppable because of the following code in JedisPool.createResource() method:

while (!done) {
    try {
    jedis.connect();
    if (password != null) {
        jedis.auth(password);
    }
    done = true;
    } catch (Exception e) {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e1) {
        }
    }
}

When no Redis daemon is available, the while loop keeps looping and the Interrupted exception is simply ignored.

As you may know, as a library developper, it is really not recommanded to catch Interrupted exception. If it is necessary, you should restore the interrupt status that the exception throwing cleared.

The following code fixes the issue:

try {
    Thread.sleep(100);
} catch (InterruptedException ignored) {
    // The repair thread can be interrupted on shutdown
    Thread.currentThread().interrupt();
    return null;
}

Note that the return null; may be acceptable there since we are in the case where the shutdown method has been called to interrupt the repair threads. So we are exiting the program.

This enables Repair threads to stop and then unblock the program shutdown.

For the moment, a quick hugly fix for those who needs the patch is to override the createResource() method and apply the above patch in it.

Thanks,

Mathieu Carbou
[email protected]

Set default JedisPool configuration to work smoothly with Redis default configuration

Redis comes configured with a default connection timeout of 300s. This can have a negative interaction with the current default configuration of the JedisPool such that in normal usage you can end up in a bad state (see issue 68). I propose that we set some default configuration for the pool that will alleviate this problem and perhaps save some developers some frustration when their pool stops working as expected:

GenericObjectPool.Config poolConfig = new GenericObjectPool.Config();
poolConfig.testWhileIdle = true;
poolConfig.minEvictableIdleTimeMillis = 60000;
poolConfig.timeBetweenEvictionRunsMillis = 30000;
poolConfig.numTestsPerEvictionRun = -1;

My feeling is that this would have a much lower impact than checking every connection on borrow which would also work. Further, we should document additional configurations and best practices for accessing the pool and recovering from error conditions.

Java 1.5

Any idea what would need to be done to support this under Java 1.5? We use Java 1.5 on all our production servers and would like to use your library, but aren't so exciting about moving to Java 1.6 in order to do so. We might, however, be able to help make the requisite changes to support Java 1.5.

Overriding of interface method is a Java 1.6 feature

Class JedisByteHashMap is annotating the methods implemented from Map<byte[], byte[]> interface as override.
Annotating interface methods as override is only possible since Java 1.6 and the project requires Java 1.5 compatibility at the moment.

Pipelined smembers return value.

I'm calling smembers from a ShardedJedisPipeline and instead of getting a Set it looks like I'm getting an ArrayList.
This is different from calling smembers without pipelining, which returns a Set.

I'm using jedis-1.3.2-jdk1.5.jar

poor performance when using utf8 characters

Hi,
I'm new to redis (only tested it yesterday) and then to jedis.
I used hmset to write 300000 entries but performance tests were really disappointing : more than 2 minutes to write only 10000 entries.

Today, I've checked the jedis code and found an issue in the RedisOuputStream class, when using utf8 characters. This is due to wrong conditions for flushing the buffer, where jedis flushed it for each chars.

Here is a small test to reproduce it :

import java.util.*;
import redis.clients.jedis.*;

public class JedisPerf {
    public static void main(String[] args) {
        String v = "éééééééééééééééééééééééééééééééééééééééééééé";
        Map<String, String> map = new HashMap<String, String>();
        for (int i = 0; i < 30; i++) {
            map.put("k" + i, v);
        }

        Jedis jedis = new Jedis("localhost");
        jedis.flushDB();
    
        long start = System.currentTimeMillis();
        for (int i = 0; i < 10000; i++) {
            jedis.hmset("id:" + i, map);
        }
        long end = System.currentTimeMillis();
        System.out.println((end - start) + " ms");
    }
}

With the current git snapshot, this is done in 401299 ms.
With the patch bellow, it took only 6452 ms :

diff --git a/src/main/java/redis/clients/util/RedisOutputStream.java b/src/main/java/redis/clients/util/RedisOutputStream.java
index d9233e9..c366e02 100644
--- a/src/main/java/redis/clients/util/RedisOutputStream.java
+++ b/src/main/java/redis/clients/util/RedisOutputStream.java
@@ -119,13 +119,13 @@ public final class RedisOutputStream extends FilterOutputStream {
                     flushBuffer();
                 }
             } else if (c < 0x800) {
-                if(2 < buf.length - count) {
+                if(2 >= buf.length - count) {
                     flushBuffer();
                 }
                 buf[count++] = (byte)(0xc0 | (c >> 6));
                 buf[count++] = (byte)(0x80 | (c & 0x3f));
             } else if (isSurrogate(c)) {
-                if(4 < buf.length - count) {
+                if(4 >= buf.length - count) {
                     flushBuffer();
                 }
                 int uc = Character.toCodePoint(c, str.charAt(i++));
@@ -134,7 +134,7 @@ public final class RedisOutputStream extends FilterOutputStream {
                 buf[count++] = ((byte)(0x80 | ((uc >> 6) & 0x3f)));
                 buf[count++] = ((byte)(0x80 | (uc & 0x3f)));
             } else {
-                if(3 < buf.length - count) {
+                if(3 >= buf.length - count) {
                     flushBuffer();
                 }
                 buf[count++] =((byte)(0xe0 | ((c >> 12))));

JedisException: Unknown reply: O

Dealing with a data set of about 100,000 key/values I am getting the attached exception when trying to

jedis.set("MyObj:MyId:label", label);

This happens roughly around the 50,000th entry. The data prior to this is stored correctly and the data after this is lost.
This is running in a grails/groovy app.

[ 30.09.2010 11:27:55] [http-8080-5] ERROR errors.GrailsExceptionResolver : 72 - Unknown reply: O
redis.clients.jedis.JedisException: Unknown reply: O
at redis.clients.jedis.Protocol.process(Protocol.java:65)
at redis.clients.jedis.Protocol.read(Protocol.java:116)
at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:121)
at redis.clients.jedis.Jedis.set(Jedis.java:49)
at TestController$_closure22.doCall(TestController:494)
at TestController$_closure22.doCall(TestController)
at com.frequency.utils.PageCacheFilter.doFilter(PageCacheFilter.java:138)
at java.lang.Thread.run(Thread.java:637)
[ 30.09.2010 11:27:55] [http-8080-5] ERROR [/].[grails] : 678 - Servlet.service() for servlet grails threw exception
java.lang.NullPointerException
at org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver.resolveException(GrailsExceptionResolver.java:75)
at com.frequency.utils.GenericExceptionHandler.resolveException(GenericExceptionHandler.java:20)
at org.springframework.web.servlet.DispatcherServlet.processHandlerException(DispatcherServlet.java:1007)
at org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.doDispatch(GrailsDispatcherServlet.java:319)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:292)
at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:260)
at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:251)
at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:183)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.obtainContent(GrailsPageFilter.java:245)
at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.doFilter(GrailsPageFilter.java:134)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.providers.anonymous.AnonymousProcessingFilter.doFilterHttp(AnonymousProcessingFilter.java:105)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.rememberme.RememberMeProcessingFilter.doFilterHttp(RememberMeProcessingFilter.java:116)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:277)
at org.codehaus.groovy.grails.plugins.springsecurity.GrailsAuthenticationProcessingFilter.super$3$doFilterHttp(GrailsAuthenticationProcessingFilter.groovy)
at sun.reflect.GeneratedMethodAccessor666.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1058)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1070)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:127)
at org.codehaus.groovy.grails.plugins.springsecurity.GrailsAuthenticationProcessingFilter.doFilterHttp(GrailsAuthenticationProcessingFilter.groovy:56)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:67)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:69)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.codehaus.groovy.grails.plugins.resourcesfirst.ResourcesFirstFilter.doFilter(ResourcesFirstFilter.java:45)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.frequency.utils.PageCacheFilter.doFilter(PageCacheFilter.java:138)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:637)
[ 30.09.2010 11:27:55] [http-8080-5] ERROR [/].[default] : 274 - Servlet.service() for servlet default threw exception
java.lang.NullPointerException
at org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver.resolveException(GrailsExceptionResolver.java:75)
at com.frequency.utils.GenericExceptionHandler.resolveException(GenericExceptionHandler.java:20)
at org.springframework.web.servlet.DispatcherServlet.processHandlerException(DispatcherServlet.java:1007)
at org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.doDispatch(GrailsDispatcherServlet.java:319)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:292)
at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:260)
at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:251)
at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:183)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.obtainContent(GrailsPageFilter.java:245)
at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.doFilter(GrailsPageFilter.java:134)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.providers.anonymous.AnonymousProcessingFilter.doFilterHttp(AnonymousProcessingFilter.java:105)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.rememberme.RememberMeProcessingFilter.doFilterHttp(RememberMeProcessingFilter.java:116)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:277)
at org.codehaus.groovy.grails.plugins.springsecurity.GrailsAuthenticationProcessingFilter.super$3$doFilterHttp(GrailsAuthenticationProcessingFilter.groovy)
at sun.reflect.GeneratedMethodAccessor666.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1058)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1070)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:127)
at org.codehaus.groovy.grails.plugins.springsecurity.GrailsAuthenticationProcessingFilter.doFilterHttp(GrailsAuthenticationProcessingFilter.groovy:56)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:67)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:69)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.codehaus.groovy.grails.plugins.resourcesfirst.ResourcesFirstFilter.doFilter(ResourcesFirstFilter.java:45)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.frequency.utils.PageCacheFilter.doFilter(PageCacheFilter.java:138)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:637)

BinaryJedisCommands does not define #select, #mget, #mset, or #msetnx

Being a newcomer to Redis, as far as I know, the commands select, mget, mset, and msetnx are valid in the binary protocol. However, they are absent from the interface BinaryJedisCommand. A corollary is that neither the shared binary interface nor the binary pipeline supper mget, etc. But, maybe a separate issue, there actually is no binary pipeline ... is this planned for a future version?

Test failures on master

Is that expected (due to some refactoring) ??
Running "mvn clean test" with a off-the-shelve Redis 2.0.2 installation:

Results :

Failed tests:
bgsave(redis.clients.jedis.tests.commands.ControlCommandsTest)

Tests in error:
persist(redis.clients.jedis.tests.commands.AllKindOfValuesCommandsTest)
lpushx(redis.clients.jedis.tests.commands.ListCommandsTest)
rpushx(redis.clients.jedis.tests.commands.ListCommandsTest)
linsert(redis.clients.jedis.tests.commands.ListCommandsTest)
trySharding(redis.clients.jedis.tests.ShardedJedisTest)
tryShardingWithMurmure(redis.clients.jedis.tests.ShardedJedisTest)
watch(redis.clients.jedis.tests.commands.TransactionCommandsTest)
unwatch(redis.clients.jedis.tests.commands.TransactionCommandsTest)
strlen(redis.clients.jedis.tests.commands.StringValuesCommandsTest)

Tests run: 151, Failures: 1, Errors: 9, Skipped: 0

no way to stop repair threads

It seems that FixedResourcePool does not provide a method to clean up nicely, including stopping the repair threads. (This is from a quick look at the source, I could be wrong...) A destroy() method or similar should be provided.

I'm investigating why my Grails application does not terminate correctly when I press Ctrl-C, this looks like a prime suspect.

Use slf4j instead of Java util logger

I think it would be better for Jedis to use slf4j instead of the java util logger. This would enable apps to determine which logger to use in production.

ArrayIndexOutOfBoundsException in RedisOutputStream using JedisPool in 1.5

We're using pooling like so:

// Get pool from app context
JedisPool pool = (JedisPool) context.getAttribute("jedis-pool");
if (pool == null) {
    log.error("Cannot get plays today, unable to get jedis pool!");
    return 0; // if pool is down, just get out
}

Jedis jedis = null;
try {
    jedis = pool.getResource();
    return Long.parseLong( jedis.hget(hash, hashKey) );
} catch (Exception e) {
    log.error("Error getting plays today", e);
} finally {
    if (jedis != null) pool.returnResource(jedis);
}

We never saw this when developing / staging, and when we first deployed the app with this code, it ran fine for maybe 10 minutes, then the following stack trace started appearing in our logs from the hget line in the code above:

java.lang.ArrayIndexOutOfBoundsException: 8208
at redis.clients.util.RedisOutputStream.write(RedisOutputStream.java:35)
at redis.clients.jedis.Protocol.sendCommand(Protocol.java:32)
at redis.clients.jedis.Protocol.sendCommand(Protocol.java:26)
at redis.clients.jedis.Connection.sendCommand(Connection.java:70)
at redis.clients.jedis.BinaryClient.hget(BinaryClient.java:172)
at redis.clients.jedis.Client.hget(Client.java:136)
at redis.clients.jedis.Jedis.hget(Jedis.java:693)

Afterwards, it seems every successive call of that line caused the same exception with varying values for the actual array index (all of which were above the 8192 length buffer in RedisOutputStream).

Add OSGi Metadata

It would be nice if this library would ship with a valid MANIFEST.MF for OSGi Bundle compatibility.
This is quite simple to achieve and would make jedis OSGi compatible (broaden the audience, make it a first class citizen in Java App Severs that leverage OSGi as Runtime already.. and so on).

(fork commit coming)

FixedResourcePool failed

I'm using jedis version on your git repository, and i have some problem with its ConnectionPool, I think RepairThread should catch exception that throw by createResource. I make a test like this:

  1. new JedisPool() <--> RedisServer did not started
  2. getResource() <--> RedisServer still down.
  3. getResource() <--> RedisServer up.
  4. getResource() <--> RedisServer down.
  5. getResource() <--> RedisServer up.

in summary, a loop try to get connection to RedisServer, put an item, server side will up/down redis-server for several times, and I hope JedisPool will wait for connection available. in my test, JedisPool turn frozen after some restart of redis-server.

Improve pipelining by queueing commands

Currently in jedis pipelining is done by reading all the replies at once. Performance could be further improved by issuing multiple commands in one go as mentioned in the protocol spec:
Pipelining is supported so multiple commands can be sent with a single write operation by the client

Can you consider adding some sort of pipelining mode to the Jedis client? In it, all commands could be added to the queue and issued at once, in bulk.
The current approach of using an abstract class requires clients to aggregate commands themselves which is difficult.

Bad processBulkReply implementation ...

The current implementation doesn't take care about TCP fragmentation ...

Little patch :

diff --git a/src/main/java/redis/clients/jedis/Protocol.java b/src/main/java/redis/clients/jedis/Protocol.java
index ff96e8b..3c1ff30 100644
--- a/src/main/java/redis/clients/jedis/Protocol.java
+++ b/src/main/java/redis/clients/jedis/Protocol.java
@@ -139,8 +139,11 @@ public class Protocol {
return null;
}
byte[] read = new byte[len];

  •   int offset = 0;
    try {
    
  •       is.read(read);
    
  •           while(offset < len) {
    
  •               offset += is.read(read, offset, (len - offset));
    
  •           }
        // read 2 more bytes for the command delimiter
        is.read();
        is.read();
    

MD5 hashing and sharding fails

I have a ShardedJedisPool with 3 shards configured to use MD5 hashing.
I'm getting this error:
java.lang.ArrayIndexOutOfBoundsException
at sun.security.provider.DigestBase.engineUpdate(DigestBase.java:110)
at sun.security.provider.MD5.implDigest(MD5.java:88)
at sun.security.provider.DigestBase.engineDigest(DigestBase.java:169)
at sun.security.provider.DigestBase.engineDigest(DigestBase.java:148)
at java.security.MessageDigest$Delegate.engineDigest(MessageDigest.java:546)
at java.security.MessageDigest.digest(MessageDigest.java:323)
at redis.clients.util.Hashing$1.hash(Hashing.java:28)
at redis.clients.util.Sharded.getShardInfo(Sharded.java:86)
at redis.clients.util.Sharded.getShardInfo(Sharded.java:96)
at redis.clients.util.Sharded.getShard(Sharded.java:82)
at redis.clients.jedis.ShardedJedisPipeline.hgetAll(ShardedJedisPipeline.java:192)

Also all keys end up in the second shard, probably related to the above error.

incrBy and hincrBy returns long but takes int

Hi, just updated a app from 1.3.2 to 1.5-RC2 and found that incr/decr and incrBy/decrBy methods returns long instead of int, as should be in the first time. But as parameter the [h][in|de]crBy methods takes still int, should be Long also. Just in case someone needs to make an in/decrBy with a value of x with x: Integer.MAX_VALUE < x < Long.MAX_VALUE or MIN_VALUE.

greets
mheuser

Maven repo

It would be amazing if you created a maven repository for this project.

Thanks for everything you do!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.