• Stars
    star
    11,542
  • Rank 2,729 (Top 0.06 %)
  • Language
    Java
  • License
    MIT License
  • Created almost 14 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Redis Java client

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

More Repositories

1

redis

Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes, Streams, HyperLogLogs, Bitmaps.
C
64,881
star
2

go-redis

Redis Go client
Go
19,143
star
3

node-redis

Redis Node.js client
TypeScript
16,619
star
4

ioredis

๐Ÿš€ A robust, performance-focused, and full-featured Redis client for Node.js.
TypeScript
13,878
star
5

redis-py

Redis Python Client
Python
12,153
star
6

hiredis

Minimalistic C client for Redis >= 1.2
C
6,040
star
7

redis-rb

A Ruby client library for Redis
Ruby
3,942
star
8

redis-doc

Redis documentation source code for markdown and metadata files, conversion scripts, and so forth
Shell
2,304
star
9

rueidis

A fast Golang Redis client that supports Client Side Caching, Auto Pipelining, Generics OM, RedisJSON, RedisBloom, RediSearch, etc.
Go
2,150
star
10

redis-om-node

Object mapping, and more, for Redis and Node.js. Written in TypeScript.
TypeScript
1,092
star
11

redis-om-python

Object mapping, and more, for Redis and Python
Python
982
star
12

redis-io

Application running http://redis.io
Ruby
637
star
13

redis-om-spring

Spring Data Redis extensions for better search, documents models, and more
Java
552
star
14

hiredis-py

Python wrapper for hiredis
C
486
star
15

redis-om-dotnet

Object mapping, and more, for Redis and .NET
C#
419
star
16

hiredis-rb

Ruby wrapper for hiredis
Ruby
317
star
17

hiredis-node

Node wrapper for hiredis
JavaScript
304
star
18

riot

๐Ÿงจ Get data in & out of Redis with RIOT
Java
227
star
19

NRedisStack

Redis Stack .Net client
C#
174
star
20

redis-rcp

Redis Change Proposals
138
star
21

redis-hashes

Redis tarball SHA1 hashes
86
star
22

redis-specifications

A bin for Redis' specs
33
star
23

redis-benchmarks-specification

The Redis benchmarks specification describes the cross-language/tools requirements and expectations to foster performance and observability standards around redis related technologies. Members from both industry and academia, including organizations and individuals are encouraged to contribute.
Python
24
star
24

redis-debian

Debian packaging
Shell
16
star
25

librdb

Redis RDB file parser, with JSON, RESP and RDB-loader extensions
C
16
star
26

redis-snap

A repository for snap packaging
10
star
27

redis-website

HTML
9
star
28

docs

Documentation for Redis, Redis Cloud, and Redis Enterprise
Python
8
star
29

redis-clinterwebz

Python
4
star
30

redis-extra-ci

4
star
31

redis-rpm

Shell
2
star