首页>代码>ssm使用redis做为spring+spring MVC+mybatis整合的二级缓存,基于maven搭建>/ssm-redis/src/main/java/com/ssm/jediscomp/impl/JedisClientSingle.java
package com.ssm.jediscomp.impl;
import org.springframework.beans.factory.annotation.Autowired;
import com.ssm.jediscomp.JedisClient;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
/**
* Author 飞鸟
* Created by kauw on 2016/10/18.
*/
public class JedisClientSingle implements JedisClient {
@Autowired
private JedisPool jedisPool;
public String get(String key) {
Jedis jedis=jedisPool.getResource();
String result=jedis.get(key);
jedis.close();
return result;
}
public String set(String key, String value) {
Jedis jedis=jedisPool.getResource();
String result=jedis.set(key, value);
jedis.close();
return result;
}
public String hget(String hkey, String key) {
Jedis jedis=jedisPool.getResource();
String result=jedis.hget(hkey, key);
jedis.close();
return result;
}
public long hset(String hkey, String key, String value) {
Jedis jedis=jedisPool.getResource();
Long result = jedis.hset(hkey, key, value);
jedis.close();
return result;
}
public long incr(String key) {
Jedis jedis=jedisPool.getResource();
Long result = jedis.incr(key);
jedis.close();
return result;
}
public long decr(String key) {
Jedis jedis=jedisPool.getResource();
Long result = jedis.decr(key);
jedis.close();
return result;
}
public long expire(String key, int second) {
Jedis jedis=jedisPool.getResource();
Long result = jedis.expire(key, second);
jedis.close();
return result;
}
public long ttl(String key) {
Jedis jedis=jedisPool.getResource();
Long result = jedis.ttl(key);
jedis.close();
return result;
}
public long del(String key) {
Jedis jedis=jedisPool.getResource();
Long result = jedis.del(key);
jedis.close();
return result;
}
public long hdel(String hkey, String key) {
Jedis jedis=jedisPool.getResource();
Long result = jedis.hdel(hkey, key);
jedis.close();
return result;
}
}
最近下载更多
微信网友_7134912998903808 LV15
2024年9月13日
qq1466625431 LV6
2022年6月28日
wei_471416461 LV1
2022年6月25日
zz56zz LV1
2021年12月19日
m_x_x_k LV1
2021年12月7日
huangshaohua LV1
2021年12月1日
疯子庭 LV8
2021年11月30日
warrior09 LV2
2021年11月16日
奇了个怪 LV1
2021年11月15日
chenhong0223 LV1
2021年11月15日
最近浏览更多
3312djdad LV2
2024年11月11日
微信网友_7134912998903808 LV15
2024年9月13日
lun123456
2024年6月23日
暂无贡献等级
educationAAA LV11
2024年5月4日
yyh1252 LV8
2023年11月16日
c469893928 LV2
2023年6月10日
youwuzuichen LV11
2023年3月27日
不止是六位数 LV7
2023年3月21日
2237851964 LV1
2023年3月12日
banerwu LV3
2023年1月3日

