redis 官网下载地址:http://redis.io/

E:\工作软件\新建文件夹\redis64-2.8.19  redis-server.exe 执行该命令

当前已启动  端口号:6379

redis.conf 该配制文件中配置登陆密码

在次下面配置################################## SECURITY ###################################

# Require clients to issue AUTH <PASSWORD> before processing any other
# commands. This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
requirepass "123456"

redis 可视化工具RedisStudio下载地址 :https://github.com/cinience/RedisStudio/releases  下载之后直接打开

填写完毕之后直接save就可以了

在此下面查找数据

redis java的增删改查:

/**
* 根据key删除value
* @param key
*/
public void remove(String key){
if(key == null || "".equals(key)){
throw new ServiceException("key值不能为空!");
}
JedisPool pool = null;
Jedis jedis = null;
try{
pool = getPool();
jedis = pool.getResource();
if(jedis.exists(key)){
jedis.del(key);
}
}catch (Exception e){
e.printStackTrace();
}finally {
if(jedis != null){
jedis.close();
}
}
} /**
* 根据key读取value值,可根据传入类型进行转型
* @param key
* @param clazz
* @param <T>
* @return
*/
public <T> T getData(String key, Class<T> clazz){
if(key == null || "".equals(key)){
throw new ServiceException("key值不能为空!");
}
Object result = null;
JedisPool pool = null;
Jedis jedis = null;
try{
pool = getPool();
jedis = pool.getResource();
result = jedis.get(key);
}catch (Exception e){
e.printStackTrace();
}finally {
if(jedis != null){
jedis.close();
}
}
JsonMapper m = new JsonMapper();
return (T) m.fromJson(String.valueOf(result), clazz);
} /**
* 新增/修改,需要传入key,value可传入对象,生存时间(单位:秒)
* @param key
* @param obj
* @param t
*/
public void save(String key, Object obj, int t){
if(key == null || "".equals(key)){
throw new ServiceException("key值不能为空!");
} if(obj == null){
throw new ServiceException("value值不能为空!");
} JsonMapper m = new JsonMapper();
String val = m.toJson(obj);
logger.debug("新增key=>" + key + "及value=>" + val);
JedisPool pool = null;
Jedis jedis = null;
try {
pool = getPool();
jedis = pool.getResource();
jedis.set(key, val);
jedis.expire(key, t);
}catch (Exception e){
e.printStackTrace();
throw new ServiceException("保存redis数据失败!");
}finally {
if(jedis != null){
jedis.close();
}
}
} /**
* 更新key的生存时间(单位:秒)
* @param key
* @param t
* @return
*/
public Long expireRow(String key, int t){
if(key == null || "".equals(key)){
throw new ServiceException("key值不能为空!");
} Long res = 0L;
JedisPool pool = null;
Jedis jedis = null;
try{
pool = getPool();
jedis = pool.getResource();
res = jedis.expire(key, t);
}catch (Exception e){
e.printStackTrace();
}finally {
if(jedis != null){
jedis.close();
}
}
return res;
} public static Map<String, Object> beanToMap(Object obj) {
if(obj == null){
return null;
}
Map<String, Object> map = new HashMap<String, Object>();
try {
BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass());
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (PropertyDescriptor property : propertyDescriptors) {
String key = property.getName(); // 过滤class属性
if (!key.equals("class")) {
// 得到property对应的getter方法
Method getter = property.getReadMethod();
Object value = getter.invoke(obj); map.put(key, value);
}
}
} catch (Exception e) {
System.out.println("transBean2Map Error " + e);
}
return map;
}

最新文章

  1. android 设计
  2. IOS 非常流畅的滑动tableView
  3. mysql create db utf8 character
  4. ubuntu安装中文支持
  5. [转] CentOS单独安装Apache Benchmark压力测试工具的办法
  6. Flex中NetConnection与NetStream的关系、及浏览器并发连接数测试[转]
  7. [C语言 - 4] 指针
  8. buffer cache chain 图
  9. 用macports装了一份openssl
  10. nice Validator参考
  11. LoadRunner 录制cas 登陆脚本
  12. [Unity Quaternion]四元数Quaternion的计算方式
  13. JS 工具 构建工具
  14. (转)log4j(三)——如何控制不同级别的日志信息的输出?
  15. JavaScript保留关键字2。
  16. 关于Data URLs svg图片显示出错和浏览器URL hash #
  17. 安装SQl Server 报错 &quot;需要 Microsoft.NET Framework 3.5 ServicePack 1&quot; 解决方法
  18. 11、JDBC-Druid
  19. 关于关键字 volatile
  20. gradle 配置及设置本地仓库

热门文章

  1. The note of Vue.js
  2. iOS10 远程推送服务器所需证书以及应用授权文件配置
  3. JHChart iOS图表工具库1.0.3新版本详解
  4. libc++abi.dylib`__cxa_throw: 视频播放时异常
  5. user agent stylesheet (浏览器默认样式)!
  6. ExtJS基础知识总结:自定义日历和ComboBox控件(二)
  7. 【Java EE 学习 80 下】【调用WebService服务的四种方式】【WebService中的注解】
  8. 【Java EE 学习 69 中】【数据采集系统第一天】【SSH框架搭建】
  9. Eclipse代码注释模板
  10. GTest Google的一种白盒单元测试框架 开源项目