This is the most common practice for everyone to learn how to use redis:
First: Download
Download redis: download the latest rediss from the official website http://redis.io /.
Http://redis.googlecode.com/files/redis-2.6.14.tar.gz
Download Jedis: Download jedis2.1.0 from https://github.com/xetorthio/jedis/downloadsand the path is:
Https://github.com/downloads/xetorthio/jedis/jedis-2.1.0.jar
Second, unzip and install
Decompress tar -zxvfredis-2.6.14.tar.gz
Go to the SRC folder, make and makeinstall. For details, see the README file.
Third: Test
Compile a test file
Package test. redis;
Import redis. Clients. Jedis. Jedis;
Import redis. Clients. Jedis. jedisshardinfo;
Public class testredisconnect {
Private Static Jedis;
Static {
Jedis = new Jedis ("127.0.0.1 ");
Jedis. Connect ();
}
/**
* @ Param ARGs
*/
Public static void main (string [] ARGs ){
// Todo auto-generated method stub
Jedis. incr ("testage ");
System. Out. println (Jedis. Get ("testage "));
}
}
Directory structure:
.
| -- Libs
| '-- Jedis-2.1.0.jar
'-- Test
'-- Redis
| -- Testredisconnect. Class
'-- Testredisconnect. Java
3 directories, 3 files
Start the redis service: redis-server redis. conf
Compile:
Javac-djava. Ext. dirs = libstest/redis/testredisconnect. Java
Run:
Java-djava. Ext. dirs = libstest. redis. testredisconnect
If 1 is entered, the test is successful. The next article describes the master-slave configuration of redis.