# jedis
**Repository Path**: wangyu90/jedis
## Basic Information
- **Project Name**: jedis
- **Description**: jedis
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: baker-v4.3.1
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 1
- **Created**: 2023-01-03
- **Last Updated**: 2023-01-03
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
```text
https://github.com/redis/jedis
https://gitee.com/baker-yuan/jedis/tree/v4.3.1/
openjdk-17
```
```text
git checkout -b baker-v4.3.1 v4.3.1
```
# Jedis
[](https://github.com/redis/jedis/releases/latest)
[](https://search.maven.org/artifact/redis.clients/jedis)
[](https://www.javadoc.io/doc/redis.clients/jedis)
[](./LICENSE.txt)
[](https://github.com/redis/jedis/actions/workflows/integration.yml)
[](https://lgtm.com/projects/g/redis/jedis/context:java)
[](https://codecov.io/gh/redis/jedis)
[](https://discord.gg/qRhBuY8Z)
## What is Jedis?
Jedis is a Java client for [Redis](https://github.com/redis/redis "Redis") designed for performance and ease of use.
Are you looking for a high-level library to handle object mapping? See [redis-om-spring](https://github.com/redis/redis-om-spring)!
## Contributing
We'd love your contributions!
**Bug reports** are always welcome! [You can open a bug report on GitHub](https://github.com/redis/jedis/issues/new).
You can also **contribute documentation** -- or anything to improve Jedis. Please see
[contribution guideline](https://github.com/redis/jedis/blob/master/.github/CONTRIBUTING.md) for more details.
## 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:
```xml
redis.clients
jedis
4.3.0
```
Next, you'll need to connect to Redis. For many applications, it's best to use a connection pool. You can instantiate a Jedis connection pool like so:
```java
JedisPool pool = new JedisPool("localhost", 6379);
```
With a `JedisPool` instance, you can use a
[try-with-resources](https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html)
block to get a connection and run Redis commands.
Here's how to run a single [SET](https://redis.io/commands/set) command within a *try-with-resources* block:
```java
try (Jedis jedis = pool.getResource()) {
jedis.set("clientName", "Jedis");
}
```
`Jedis` instances implement most Redis commands. See the
[Jedis Javadocs](https://www.javadoc.io/doc/redis.clients/jedis/latest/redis/clients/jedis/Jedis.html)
for the complete list of supported commands.
### Easier way of using connection pool
Using a *try-with-resources* block for each command may be cumbursome, so you may consider using JedisPooled.
```java
JedisPooled jedis = new JedisPooled("localhost", 6379);
```
Now you can send commands like sending from Jedis.
```java
jedis.sadd("planets", "Venus");
```
## Connecting to a Redis cluster
Jedis lets you connect to Redis Clusters, supporting the [Redis Cluster Specification](https://redis.io/topics/cluster-spec).
To do this, you'll need to connect using `JedisCluster`. See the example below:
```java
Set jedisClusterNodes = new HashSet();
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:
```java
jedis.sadd("planets", "Mars");
```
## Using Redis modules
Jedis includes support for [Redis modules](https://redis.io/docs/modules/) such as
[RedisJSON](https://oss.redis.com/redisjson/) and [RediSearch](https://oss.redis.com/redisearch/).
See the [RedisJSON Jedis](docs/redisjson.md) or [RediSearch Jedis](docs/redisearch.md) for details.
## Documentation
The [Jedis wiki](http://github.com/redis/jedis/wiki) contains several useful articles for using Jedis.
You can also check the [latest Jedis Javadocs](https://www.javadoc.io/doc/redis.clients/jedis/latest/index.html).
## Troubleshooting
If you run into trouble or have any questions, we're here to help!
Hit us up on the [Redis Discord Server](http://discord.gg/redis) or [open an issue on GitHub](https://github.com/redis/jedis).
You can also find help on the [Jedis mailing list](http://groups.google.com/group/jedis_redis) or the
[GitHub Discussions](https://github.com/redis/jedis/discussions).
## License
Jedis is licensed under the [MIT license](https://github.com/redis/jedis/blob/master/LICENSE.txt).
## Sponsorship
[](https://redis.com/)