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;
}

redis 下载及使用的更多相关文章

  1. Redis下载及安装部署

    官网介绍:Redis is an open source advanced key-value store.It is often referred to as a data structure se ...

  2. (1)redis下载编译

    一.redis下载编译 这里没什么好说的 用的版本是redis-2.8.17 1)redis-server是可执行程序 2)mian函数在redis.c里面 3)如果要修改调试 这届在src目录下   ...

  3. centos6.5环境Redis下载及编译安装

    centos6.5环境Redis下载及编译安装 1:官方站点: http://redis.io/download 下载最新版或者最新stable版 2:解压源码并进入目录 tar -zxvf redi ...

  4. Redis 下载 安装

    Redis 官网 https://redis.io/ github 主页 https://github.com/antirez/redis 下载页面 https://redis.io/download ...

  5. Windows上redis下载与安装

    一.redis是什么 非关系型内存数据库,以key-value的形式将数据储存在内存中.Mysql是关系型数据库,数据是保存在硬盘中 二.redis下载安装 1.要安装Redis,首先要获取安装包. ...

  6. Redis 下载与配置window服务

    1.Redis下载 Git下载地址:https://github.com/MicrosoftArchive/redis/releases 2.配置Window服务 步骤一:在 Redis目录 输入 c ...

  7. redis基础:redis下载安装与配置,redis数据类型使用,redis常用指令,jedis使用,RDB和AOF持久化

    知识点梳理 课堂讲义 课程计划 1. REDIS 入 门 (了解) (操作)   2. 数据类型 (重点) (操作) (理解) 3. 常用指令   (操作)   4. Jedis (重点) (操作) ...

  8. Redis下载安装与配置(windows)

    一.Redis下载 Redis官网建议使用Linux进行部署,未提供windows版本的Redis,但微软开发和维护着Windows64版本的Redis. Windows64版本的Redis下载地址: ...

  9. redis 下载启动,设置、查询超时时间

    1.定义 redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合).zset(sorted ...

随机推荐

  1. npm提速

    解决办法:npm --> cnpm https://npm.taobao.org

  2. uiautomator-----UiWatcher监听器

    一.UiWatcher类说明 1.Uiwatcher用于处理脚本执行过程中遇到非预想的步骤 2.UiWatcher使用场景 1)测试过程中来了一个电话 2)测试过程中来了一条短信 3)测试过程中闹钟响 ...

  3. 关于httpd服务的安装、配置

    httpd是Apache超文本传输协议(HTTP)服务器的主程序.通常,httpd不应该被直接调用,而应该在linux系统中由 apachectl 调用.接下来我们将了解有关httpd服务的安装与配置 ...

  4. [转]C/C++ 程序员必须收藏的资源大全

    from: https://github.com/jobbole/awesome-cpp-cn C++ 资源大全中文版 我想很多程序员应该记得 GitHub 上有一个 Awesome – XXX 系列 ...

  5. python 登录小程序

    运行程序前,需在本目录增加黑名单文件 # Author:JinYu # -*- coding:utf-8 -*- #登录3次锁定 local_username = 'jinyu' local_pass ...

  6. C语言 遍历流程 变量生命周期

    来自c程序设计 谭浩强 程序编译流程 运行c程序的步骤 在编好一个c程序后.怎样上机进行编译运行呢?一般要经过一下几个步骤: 上机输入和编辑源程序.通过键盘和计算机输入程序,如果发现有错误,要及时改正 ...

  7. PHP预定义接口之 ArrayAccess

    最近这段时间回家过年了,博客也没有更新,感觉少学习了好多东西,也错失了好多的学习机会,就像大家在春节抢红包时常说的一句话:一不留神错过了好几亿.废话少说,这篇博客给大家说说关于PHP预定义接口中常用到 ...

  8. Ubuntu下安装JDK以及相关配置

    1.查看系统位数,输入以下命令即可 getconf LONG_BIT 2.下载对应的JDK文件,我这里下载的是jdk-8u60-linux-64.tar.gz 3.创建目录作为JDK的安装目录,这里选 ...

  9. 使用Nito.AsyncEx实现异步锁(转)

    转载地址:http://www.cnblogs.com/1zhk/p/5269279.html Lock是常用的同步锁,但是我们无法在Lock的内部实现异步调用,比如我们无法使用await. 以下面的 ...

  10. Google Analytics 链接点击次数记录

    <span> <a href="http://protect-your-family.hansaplast.com.my/upload/<?php echo $fil ...