Commit 167ed878 authored by zhushanglei's avatar zhushanglei

gps数据采集修改redis

parent 5a999eeb
package client;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.params.SetParams;
public class RedisUtils {
/**
* 普通缓存放入并设置时间
*
* @param key 键
* @param value 值
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
* @return true成功 false 失败
*/
public static boolean set(String key, String value, long time) {
Jedis jedis = null;
try {
if (time > 0) {
jedis = JedisConnectFactory.getJedis();
SetParams params = new SetParams();
params.ex(time);
jedis.set(key, value,params);
}
return true;
} catch (Exception e) {
return false;
}finally {
jedis.close();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment