1、redis定义
REmote DIctionary Server(Redis)是一个由Salvatore Sanfilippo写的key-value存储系统。它通常被称为数据结构服务器,因为值(value)可以是字符串(String)、哈希(Map)、列表(list)、集合(sets)和有序集合(sorted sets)等类型。
2、实例
(1)项目结构
(2)pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.hwd</groupId>
<artifactId>redis01</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>redis01</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
</dependencies>
</project>
(3)Test.java
package cn.hwd.test;
import redis.clients.jedis.Jedis;
public class Test {
@org.junit.Test
public void test() {
Jedis jedis = new Jedis("192.168.17.128");
jedis.auth("123456");
String result = jedis.ping();
System.out.println(result);
}
}
(4)运行结果