Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsJul 13, 2026·3 min de lecture

Jedis — Battle-Tested Java Client for Redis

Jedis is a lightweight, synchronous Java client library for Redis, offering straightforward APIs for commands, pipelines, transactions, and Lua scripting.

Prêt pour agents

Staging sûr pour cet actif

Cet actif est d'abord staged. Le prompt copié demande à l'agent d'inspecter les fichiers staged avant d'activer scripts, config MCP ou config globale.

Stage only · 29/100Policy : staging
Surface agent
Tout agent MCP/CLI
Type
CLI Tool
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Jedis Overview
Commande de staging sûr
npx -y tokrepo@latest install f3c6ef0f-7eb8-11f1-9bc6-00163e2b0d79 --target codex

Stage les fichiers d'abord; l'activation exige la revue du README et du plan staged.

Introduction

Jedis is a synchronous, blocking Java client for Redis maintained under the official redis organization on GitHub. It provides a direct mapping of Redis commands to Java methods, making it simple to adopt. Jedis is one of the two recommended Java clients alongside Lettuce.

What Jedis Does

  • Executes all Redis commands via a clean, method-per-command Java API
  • Supports connection pooling through JedisPool and the newer JedisPooled wrapper
  • Provides pipelining to batch multiple commands into a single network round trip
  • Handles Redis transactions (MULTI/EXEC) and Lua script evaluation (EVAL)
  • Connects to Redis Cluster and Redis Sentinel for high-availability setups

Architecture Overview

Jedis uses a simple blocking I/O model: each Jedis instance wraps a single TCP socket to a Redis server. For concurrent applications, JedisPool manages a pool of these instances backed by Apache Commons Pool 2. The newer JedisPooled class simplifies usage by auto-borrowing and returning connections per call. For Redis Cluster, JedisCluster discovers the slot-to-node mapping and routes commands accordingly.

Self-Hosting & Configuration

  • Add the Jedis Maven or Gradle dependency to your Java project
  • Create a JedisPooled instance pointing to your Redis host and port
  • Configure pool size via GenericObjectPoolConfig (maxTotal, maxIdle, minIdle)
  • For Redis Cluster, use JedisCluster with a set of seed HostAndPort entries
  • For Sentinel, use JedisSentinelPool with the master name and sentinel addresses

Key Features

  • Full coverage of Redis commands including Streams, JSON, and Search modules
  • Built-in connection pooling with configurable eviction and validation policies
  • Pipeline mode for batching commands and reducing network round trips
  • Support for Redis Cluster automatic slot discovery and failover
  • Lightweight dependency chain: only Apache Commons Pool 2 and SLF4J

Comparison with Similar Tools

  • Lettuce — async and reactive; Jedis is simpler but synchronous only
  • Redisson — higher-level distributed objects and locks; Jedis is lower-level
  • Spring Data Redis — abstracts over Jedis or Lettuce with Spring integration
  • ioredis (Node.js) — similar philosophy but for the JavaScript ecosystem
  • redis-py (Python) — the Python equivalent of Jedis

FAQ

Q: Jedis vs Lettuce — which should I pick? A: Use Jedis for simple, blocking workloads. Use Lettuce if you need non-blocking I/O, reactive streams, or shared connections across threads.

Q: Is Jedis thread-safe? A: A single Jedis instance is not thread-safe. Use JedisPool or JedisPooled for concurrent access.

Q: Does Jedis support Redis modules like RedisJSON? A: Yes. Jedis 4.x+ includes APIs for RedisJSON, RediSearch, RedisBloom, and RedisTimeSeries.

Q: Can I use Jedis with Spring Boot? A: Yes. Spring Data Redis supports Jedis as an alternative to its default Lettuce driver.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires