Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple spring boot app that inserts 1M random key into redis using one connection and pipelining
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.context.annotation.*;
import redis.clients.jedis.*;
import java.util.UUID;
public class RedisMassImport {
JedisPool jedisPool() {
JedisPoolConfig poolConfig = new JedisPoolConfig();
return new JedisPool(poolConfig, "localhost", 6379, 30);
CommandLineRunner init(JedisPool pool) {
return args -> {
int numKeys = 1_000_000;
try (Jedis jedis = pool.getResource()) {
// prepare UUIDs
String[] uuids = new String[numKeys];
for (int i = 0; i < numKeys; ++i)
uuids[i] = UUID.randomUUID().toString();
long time = System.nanoTime();
Pipeline p = jedis.pipelined();
for (int i = 0; i < numKeys; ++i)
p.set(uuids[i], uuids[i]);
long endTime = System.nanoTime();
System.out.println("\tTook " + (endTime - time) + "ns to sync the pipeline.");
public static void main(String[] args) {, args);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.