Redis compares Memcached and installs and configures it in CentOS
Learn about Redis
Redis is an open-source Key-Value database that supports networks, memory-based, and Key-Value pairs. it is written in ansi c and provides APIs in multiple languages. it has almost no difficulty in getting started, it takes only a few minutes for us to complete the installation and let it start to work smoothly with the application. In other words, you only need to invest a small amount of time and energy to achieve immediate and outstanding performance improvement, that is, it is a very simple cache solution. It supports the storage of Value types not only strings, but also master-slave synchronization and data persistence. everyone thinks Redis is the most popular Key-Value storage database. Are you sure you want to ask about Memcached?
Redis VS Memcached
First of all, I just went to the DB-Engines.com database rankings to see, Redis ranked ninth, Key-value store first; Memcached ranked 23, Key-value store second. Of course, this cannot be explained.
Redis supports more data types, including String, Hash, List, and Set. Memcached only supports one String data type.
Redis supports the concept of transactions through commands such as Multi/Watch/Exec, and executes a batch of commands atomically. in the Memcached application mode, apart from atomic operation commands such as increment and decrement, transactions are not supported.
Redis can configure the server in the master-slave mode to implement master-slave synchronous backup, and only supports two persistence solutions at the same time. Memcached does not guarantee the validity of the stored data, nor does it work persistently. Of course, this cannot be explained.
Every kind of things exists in this world. Although Memcached's internal memory management mechanism is not as complicated as Redis's, it is more efficient, because Memcached consumes less memory resources when processing metadata; in terms of horizontal scaling, it is also more advantageous than Redis, because of its design trend and relatively simpler function settings. For example, Memcached is better to cache a string or Html page.
Install Redis in CentOS
1. download, decompress, and install redis. here is the latest version 3.2.5 downloaded from the official website, and it is still downloaded through wget (I like this method ).
wget http://download.redis.io/releases/redis-3.2.5.tar.gztar xzf redis-3.2.5.tar.gzmv redis-3.2.5 /usr/local/redis
The above mv redis-3.2.5/usr/local/redis command is to move the Redis installation file to the installation directory, of course, this directory you can customize.
2. go to the directory and compile and install
cd /usr/local/redismakemake install
After the installation is complete, the executable scripts such as redis-server and redis-cli are displayed in the/usr/local/bin/directory, we need to decompress the directory and copy it in.
Cd/usr/local/bin/
3. configure redis. conf
Go back to the/usr/local/redis directory for configuration:
cd ../redisvim redis.conf
After modification, save and exit.
4. start
cd /usr/local/bin/redis-server /usr/local/redis/redis.confnetstat -anp | grep 6379
Connect to Redis in command line mode for a simple setup and cache retrieval test.
Redis-cli # connect to Redis, which is local by default. Keys * # View all current keyset name mafly # set a cache object with key 'name' and value 'mafly. Get name # obtain the cache with the key 'name'
It can be seen through netstat that the port is already in the TIME_WAIT status.
To sum up
After this installation and configuration of Redis, I also learned more about Memcached and the advantages and disadvantages of the two most popular Key-Value cache services, of course, most of them are obtained through the network, and how to monitor them in actual use.