Redis Introduction
Redis is an open-source, network-supported, memory-based, key-Value Pair storage database written in ansi c. For details, click here.
Install redis
My linux operating system is ubuntu12.04
Log on to the http://www.redis.io/download to download redis-2.8.3.tar.gz
(Or use commands to download ,)
Tar-zxf redis-2.8.3.tar.gz # Extract
Cd redis-2.8.3
Sudo make
Sudo make install
In this way, the Redis executable file is stored in/usr/local/bin.
After compilation and installation, a prompt is displayed for testing,
Type the command: make test
After running, a prompt is displayed:
\ O/All tests passed without errors!
Congratulations! The installation is successful !.
Redis Configuration
Make install only installs binary files on your system, and does not configure the init script and configuration file for you by default. to use it in the production environment, Redis provides
Such a script install_server.sh.
$ Sudo cd utils # Go To The utils directory under the redis-2.8.3 directory
$ Sudo./install_server.sh
When the script is executed, there may be several problems such as config settings. (Press ENTER ). All configurations required for running redis as the background daemon are set. You can use/etc/init. d/redis _ <portnumber>, for example, the script in/etc/init. d/redis_6379 to start and stop Redis.
:
Type the following command:
To start the redis service. Type a command to stop the redis service.
You can also run the command/usr/local/redis/bin/redis-server/usr/local/redis/etc/redis. conf, you can stop the Redis instance through shutdown. The specific command is redis-cli shutdown.
Run ps-ef | grep 6379 to check whether the service is started.
6379-why does Redis use it as the default port number? Click here.
Simple use of redis
Enter the redis-cli command on the terminal to connect to the client.
Add, delete, modify, and query redis:
Add: The data insertion command is set to set a key-value pair.
Set keys 100
Query data:
Get key
Check whether the verification key exists:
Exists key
(Integer) 0
0 indicates that the key does not exist; 1 indicates that the key exists.
Delete key value:
Del key
Delete the key and the corresponding value.
Execution result:
Redis is an excellent NOSQL database. Its functions and implementation principles are worth learning next.
References:
Http://www.linuxidc.com/Linux/2012-03/57573.htm
Http://langgufu.iteye.com/blog/1434408