Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clean redis cache through java program?

I have spring boot project. I am using redis as cache manager. I want to clear redis cache with java program. I want to call one api and it will clear my cache.

I already know about redis-cli flushdb command.

I am not expecting command line code. Redis cache server can be on any machine.

like image 860
S Khandelwal Avatar asked Jun 22 '26 17:06

S Khandelwal


1 Answers

Jedis jedis = new Jedis(getHost(), getPort());
jedis.connect();
jedis.flushAll();
jedis.disconnect();
like image 63
samsudeen zubair Avatar answered Jun 24 '26 08:06

samsudeen zubair



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!