Redis Study Notes --- installation, redis Study Notes ---
Introduction
As more and more Internet companies begin to use Redis for practical projects, and many people have been discussing the architecture design of Redis, it is suitable for learning. so I had some knowledge about Redis after work and made my study notes into a blog.
Redis is hosted on github as an open-source project. You can use it on github or its official website. i/O obtains the source code of the Redis project. The latest stable version of Redis is 3.0.2. Compared with Redis2.X, Redis 3.0.2 mainly adds the cluster function. before Redis 3.0.2, some internet companies have implemented some cluster functions based on Redis, or use proxies to implement cluster functions.
Install Redis
The installation of Redis is very simple. After obtaining the source code, execute the following command:
Tar-xvf redis-3.0.2.tar.gz cd redis-3.0.2makemake installcd utils./install_server.sh # When you execute install_server.sh, you will be asked to select the relevant configuration information, press enter to use the default configuration, or select your own configuration
Run the command in any directory after installation.
redis-server /etc/redis/6379.conf
A redis service will be started. Of course, if multiple configuration files are selected, multiple redis services will be started, but each redis service must specify an unused port, the default port number of the redis service is 6379 (for redis, use 6379 as the default port number. Please use Baidu gossip !!). Basic use of redis
After Redis is installed, there will be redis-server, redis-cli executable programs, redis-server is used to start the redis service, redis-cli is the redis client, used to connect to the redis database.
Redis-cli # connect to the redis service with the local default port. Use redis-cli-h host-p port to connect to any redis service 127.0.0.1: 6379> set name "gucb" OK127.0.0.1: 6379> set test testOK127.0.0.1: 6379> get test "test" 127.0.0.1: 6379> keys * # view all keys in the database 1) "test" 2) "name"
Use the Redis Python Client
You can use the easy_install program to install the Python client of Redis easily. Of course, you can also download the source code for installation.
Sudo easy_install redis python >>> import redis ## if no error is reported, the installation is correct >>> r = redis. redis (host = 'localhost', port = 6379, db = 0) >>> r. get ('name') 'gucb'
Summary
Compared with other software, redis is relatively simple to install and use. In addition, redis provides more data types than memcache, which also enables redis to use more application scenarios. the following blog will record some notes on using the basic redis data types.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.