jedis README

The project's README from github.com/redis/jedis. As one markdown file: README.md.

Jedis

Release Maven Central Javadocs MIT licensed 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

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 7.2, 7.4, 8.0, 8.2, 8.4, 8.6, 8.8 and 8.10.

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

Jedis version Supported Redis versions JDK Compatibility
3.9+ 5.0 to 6.2 Family of releases 8, 11
>= 4.0 Version 5.0 to 7.2 Family of releases 8, 11, 17
>= 5.0 Version 6.0 to current 8, 11, 17, 21
>= 5.2 Version 7.2 to current 8, 11, 17, 21
>= 6.0 Version 7.2 to current 8, 11, 17, 21
>= 7.0 Version 7.2 to current 8, 11, 17, 21
>= 8.0 Version 7.2 to current 8, 11, 17, 21, 25

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>8.0.1</version>
</dependency>

To use the cutting-edge Jedis, check here.

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

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

You can instantiate a RedisClient like so:

RedisClient jedis = RedisClient.builder().hostAndPort("localhost", 6379).build();

Now you can send commands:

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 RedisClusterClient. 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));
RedisClusterClient jedis = RedisClusterClient.builder().nodes(jedisClusterNodes).build();

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

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

Support for Redis data types

Jedis includes support for all Redis data types and features such as JSON and VectorSets.

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.

Token-Based Authentication

Jedis supports Token-Based authentication (TBA) starting with 5.3.0 GA release. This feature is complemented by an extension library that enhances the developer experience and provides most of the components required for TBA functionality.

Notably, the extension library includes built-in support for Microsoft EntraID, offering a seamless integration as part of the generic solution.

For more details and examples, please refer to the Advanced Usage documentation.

Documentation

The Jedis documentation site 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.

Contributing

We'd love your contributions!

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

To report a security vulnerability, please follow our Security Policy.

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 (redis/jedis)

Searching Database…

12.4K ·GitHub
这是什么?Jedis 是一个面向 Redis 的 Java 客户端库,注重性能和易用性,让 Java 应用能够与 Redis 服务器、集群或 Redis Enterprise 部署进行通信。
它是完整的 ORM,还是轻量级客户端?它是一个底层客户端,直接发送 Redis 命令。如果你想在 Redis 之上做对象映射,README 中指向了另一个项目 redis-om-spring。
我该如何把 Jedis 添加到项目中?将 Jedis 添加为 Maven 依赖,然后连接 Redis 服务器(可以用 Docker 快速启动一个),再实例化一个 RedisClient 即可开始发送命令。
它支持哪些 Redis 和 JDK 版本?当前版本的 Jedis 支持 Redis 7.2 至 8.10,并根据所用的 Jedis 版本支持 JDK 8、11、17、21 或 25。
Jedis 开箱即用地支持 Redis 集群和故障转移配置吗?是的。Jedis 提供了专门用于 Redis Cluster Specification 部署的 RedisClusterClient,并内置了针对多部署或主动-主动(active-active)Redis Enterprise 环境的重试和故障转移支持。
Jedis 支持 JSON 和向量数据类型吗?支持。Jedis 涵盖所有 Redis 数据类型和功能,例如 JSON 和 VectorSets。
支持基于令牌的身份验证吗?支持。自 5.3.0 GA 正式版起,Jedis 支持基于令牌的身份验证(TBA),并通过扩展库内置支持 Microsoft EntraID。
Creator
redis
Size
19.3 MB
Stars
12.4K
Age
16y
Commits · 90 Days