Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

Redis pipeline usage

$
0
0

I'm trying to understand how pipeline works nad want to try something different. I've noticed that there's no method for setting expire key if the key doesn't have any so I made an example for that with Jedis.

Example

Map<String, Response> responses = new HashMap<>();long start = System.currentTimeMillis();try (Jedis resource = redisManager.getResource()) {    Pipeline pipeline = resource.pipelined();    responses.put("time", pipeline.ttl(args[1]));    pipeline.sync();    pipeline.multi();    if (responses.get("time").get().equals(-1L)) {        pipeline.expire(args[1], 15);    }    pipeline.exec();}

I'd like to know that should I use like that or do you have any idea about it? I couldn't find any solution for that.


Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>