Redis Key expire notification with Jedis

前端 未结 2 2134
执念已碎
执念已碎 2020-12-03 03:35

I am trying to implement a expiry key notification with redis ,when my key expires in the redis data store. The redis website provides some description of how http://redis.i

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-03 04:28

    This may help you.

            JedisPool jedisPool=null;
            JedisPoolConfig poolConfig = null;
    
            try {
    
                poolConfig=new JedisPoolConfig();
                jedisPool = new JedisPool(poolConfig,"127.0.0.1" /*Host IP*/,1234 /*Port*/, 0);             
                Jedis jedis=jedisPool.getResource();            
                jedis.expire("KeyName", 10 /*Key Expires in 10 seconds*/);  
    
            } catch (Exception e) {
    
            }
    

提交回复
热议问题