diff --git a/content/develop/use-cases/prefetch-cache/java-jedis/DemoServer.java b/content/develop/use-cases/prefetch-cache/java-jedis/DemoServer.java
index 186f7cf455..e06ba288c6 100644
--- a/content/develop/use-cases/prefetch-cache/java-jedis/DemoServer.java
+++ b/content/develop/use-cases/prefetch-cache/java-jedis/DemoServer.java
@@ -1,8 +1,7 @@
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
-import redis.clients.jedis.JedisPool;
-import redis.clients.jedis.JedisPoolConfig;
+import redis.clients.jedis.RedisClient;
import java.io.IOException;
import java.io.InputStream;
@@ -28,9 +27,9 @@
* without ever falling back to the primary on the read path.
*
* {@code
- * javac -cp jedis-5.1.2.jar:slf4j-api-2.0.13.jar \
+ * javac -cp jedis-8.0.2.jar:commons-pool2-2.13.1.jar:slf4j-api-1.7.36.jar:gson-2.14.0.jar:json-20260719.jar:redis-authx-core-0.1.1-beta2.jar \
* PrefetchCache.java MockPrimaryStore.java SyncWorker.java DemoServer.java
- * java -cp .:jedis-5.1.2.jar:slf4j-api-2.0.13.jar \
+ * java -cp .:jedis-8.0.2.jar:commons-pool2-2.13.1.jar:slf4j-api-1.7.36.jar:gson-2.14.0.jar:json-20260719.jar:redis-authx-core-0.1.1-beta2.jar \
* DemoServer --port 8785 --redis-host localhost --redis-port 6379
* }
*/
@@ -39,7 +38,7 @@ public class DemoServer {
private static PrefetchCache cache;
private static MockPrimaryStore primary;
private static SyncWorker sync;
- private static JedisPool jedisPool;
+ private static RedisClient jedis;
public static void main(String[] args) {
String host = "127.0.0.1";
@@ -79,14 +78,14 @@ public static void main(String[] args) {
}
try {
- jedisPool = new JedisPool(new JedisPoolConfig(), redisHost, redisPort);
- jedisPool.getResource().close();
+ jedis = RedisClient.create(redisHost, redisPort);
+ jedis.ping();
} catch (Exception e) {
System.err.printf("Failed to connect to Redis at %s:%d: %s%n", redisHost, redisPort, e.getMessage());
System.exit(1);
}
- cache = new PrefetchCache(jedisPool, cachePrefix, ttlSeconds);
+ cache = new PrefetchCache(jedis, cachePrefix, ttlSeconds);
primary = new MockPrimaryStore(primaryLatencyMs);
sync = new SyncWorker(primary, cache);
@@ -121,12 +120,12 @@ public static void main(String[] args) {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
sync.stop();
server.stop(0);
- jedisPool.close();
+ jedis.close();
}));
} catch (IOException e) {
System.err.println("Failed to start server: " + e.getMessage());
sync.stop();
- jedisPool.close();
+ jedis.close();
System.exit(1);
}
}
diff --git a/content/develop/use-cases/prefetch-cache/java-jedis/PrefetchCache.java b/content/develop/use-cases/prefetch-cache/java-jedis/PrefetchCache.java
index e323d5c5ee..c207685036 100644
--- a/content/develop/use-cases/prefetch-cache/java-jedis/PrefetchCache.java
+++ b/content/develop/use-cases/prefetch-cache/java-jedis/PrefetchCache.java
@@ -6,10 +6,9 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
-import redis.clients.jedis.Jedis;
-import redis.clients.jedis.JedisPool;
+import redis.clients.jedis.AbstractTransaction;
import redis.clients.jedis.Pipeline;
-import redis.clients.jedis.Transaction;
+import redis.clients.jedis.RedisClient;
import redis.clients.jedis.params.ScanParams;
import redis.clients.jedis.resps.ScanResult;
@@ -33,7 +32,7 @@ public class PrefetchCache {
public static final String DEFAULT_PREFIX = "cache:category:";
public static final int DEFAULT_TTL_SECONDS = 3600;
- private final JedisPool pool;
+ private final RedisClient jedis;
private final String prefix;
private final int ttlSeconds;
@@ -45,18 +44,18 @@ public class PrefetchCache {
private double syncLagMsTotal;
private long syncLagSamples;
- public PrefetchCache(JedisPool pool) {
- this(pool, DEFAULT_PREFIX, DEFAULT_TTL_SECONDS);
+ public PrefetchCache(RedisClient jedis) {
+ this(jedis, DEFAULT_PREFIX, DEFAULT_TTL_SECONDS);
}
- public PrefetchCache(JedisPool pool, String prefix, int ttlSeconds) {
- if (pool == null) {
- throw new IllegalArgumentException("pool is required");
+ public PrefetchCache(RedisClient jedis, String prefix, int ttlSeconds) {
+ if (jedis == null) {
+ throw new IllegalArgumentException("jedis is required");
}
if (ttlSeconds < 1) {
throw new IllegalArgumentException("ttlSeconds must be at least 1 second");
}
- this.pool = pool;
+ this.jedis = jedis;
this.prefix = (prefix == null || prefix.isEmpty()) ? DEFAULT_PREFIX : prefix;
this.ttlSeconds = ttlSeconds;
}
@@ -96,8 +95,7 @@ public Result(Map record, boolean hit, double redisLatencyMs) {
*/
public int bulkLoad(Iterable