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. 排序map

    1.根据map的值,升序排序 Map<String, Integer> map = new TreeMap<String, Integer>(); map.put(" ...

  2. Delphi中DBChart的数据库应用

    一:属性相关:Series选项: (1)Format页(数据柱的风格) 在Color Each中打勾,就可使用多种颜色显示,color按钮用于设置颜色,Style用于设置图表的风格(Rectangle ...

  3. 3dmax导出到blend或者vs中

    使用3dmax将模型导成obj格式的时候,可以导出材质或者不导出. 1.如果不导出,则按下图不勾选导出材质和创建材质库选项.这样生成的obj是可以直接再blend或者vs中打开的. 2.如果导出,不仅 ...

  4. 同个项目写webservice引用EF出现的问题

    错误1: 定的架构无效.错误: DataModel.ssdl(2,2) : 错误 0152: 未找到具有固定名称“System.Data.SqlClient”的 ADO.NET 提供程序的实体框架提供 ...

  5. git 创建分支 并 提交到远程分支

    git branch(分支命令的使用http://hbiao68.iteye.com/blog/2055493 0.可以通过git branch -r 命令查看远端库的分支情况 1,从已有的分支创建新 ...

  6. [转载] 构造linux 系统下免密码ssh登陆  _How to establish password-less login with SSH

    In present (post production) IT infrastructure many different workstations, servers etc. have to be ...

  7. memcache的lru删除机制

    惰性删除,get时才删除 LRU原理:当某个单元被请求的时候,维护一个计数器,通过计数器来判断最近谁最少使用,那就把谁踢出去. 注:即使某个key设置的永久有效,也会被踢出来,这个就是永久数据被踢的现 ...

  8. [WebKit内核] JavaScript引擎深度解析--基础篇(一)字节码生成及语法树的构建详情分析

    [WebKit内核] JavaScript引擎深度解析--基础篇(一)字节码生成及语法树的构建详情分析 标签: webkit内核JavaScriptCore 2015-03-26 23:26 2285 ...

  9. AsyncTask异步上传文本到服务器

    服务器代码:用于接收客户端信息 package ches; import java.io.IOException; import java.io.PrintWriter; import javax.s ...

  10. python学习 1基础

    对象的等于只是对于值而言 函数定义没有变量提升 常用对象 list []: 列表, 排序省空间 tuple (): 元组,一旦初始化不可修改 dict {}: 字典,方便查询 set {}:集合, 值 ...