Redis本质上是一个Key-Value类型的内存数据库。
1)下载redis服务:https://github.com/dmajkic/redis/downloads
解压有如下文件:
2)下载jedis(jar):https://github.com/xetorthio/jedis/downloads
3)新建java项目RedisTest及测试类:
[java]?view plaincopy
?
class="dp-j" style="border: none; background-color: #ffffff; color: #5c5c5c; margin-bottom: 1px !important; margin-left: 45px !important;">
- import?redis.clients.jedis.Jedis;??
- public?class?JedisDemo?{????
- ????public?static?void?main(String[]?args)?{??
- ????????Jedis?jj?=?new??Jedis("localhost");??
- ????????jj.set("key1",?"I?am?value?1");??
- ????????String?ss?=?jj.get("key1");??
- ????????System.out.println(ss);??
- ????}??
- }??
4)导入jedis-2.0.0.jar
5)运行redis服务redis-server.exe
6)运行JedisDemo项目,输出:I am value 1