Redis용 자바 클라이언트. 동기 블로킹 방식의 단순한 API로 동작한다.

기본 사용법

// Maven
// <dependency>
//   <groupId>redis.clients</groupId>
//   <artifactId>jedis</artifactId>
//   <version>...</version>
// </dependency>

JedisPoolConfig config = new JedisPoolConfig();
config.setMaxTotal(50);
config.setMaxIdle(10);
config.setMinIdle(2);
config.setTestOnBorrow(true);

JedisPool pool = new JedisPool(config, "localhost", 6379, 2000, "password");

try (Jedis jedis = pool.getResource()) {
    jedis.setex("session:abc", 3600, "{\"userId\": 42}");
    jedis.incrBy("page:views:home", 5);
}

JedisPool에서 Jedis 인스턴스를 가져와 레디스를 다루는 단순한 구조임.

여기서 중요한건 Jedis 인스턴스들은 자체로 스레드 세이프하지 않다는 점. 스레드 안정성까지 챙기려면 대안 클라이언트로 Lettuce, Redisson 등을 사용해야 한다. 특히 비동기 처리가 필요한 경우,(WebFlux 사용 등) 대대안은 Lettuce임.