Jedis — Unsupported Redis Commands.

Sachin Kottarathodi
1 min readApr 24, 2020

How to use Jedis to call Redis commands that are not supported by the Jedis client yet.

When Redis comes up with new commands or modules, there is a possibility that those commands are not supported by Jedis yet.

However, there is no need to look beyond Jedis for such use cases.

First, we will look at how Jedis client really makes the Redis command calls and then see how to extend it for custom commands.

The commands supported by Jedis can be found here and in the source code here.

Let’s take an example of the ‘hset’ command supported by the Jedis client.

The implementation is as below in Jedis Client class:

All the commands in the Client class are wrappers to the commands in the Binary Client class. “hset” in Binary Client is as below.

The first argument to sendCommand is an enum of type ProtocolCommand, followed by varargs, which are the arguments as required by the Redis command.

Now, all that is required for you is to have custom enum defined that implements the ProtocolCommand.

Here is an example of the Redis Cuckoo Filter command which is not yet supported by Jedis.

cf.exists filterName keyToLookUp// look for keyToLookUp in the Cuckoo filter by name filterName.

Below is the command definition

And use this enum in sendCommand.

Jedis jedis = jedisPool.getResource(); 
jedis.sendCommand(CustomCommand.CFEXISTS, "filterName", "keyToSearch");

--

--