The official description of Redis:
Redis is a open source, BSD licensed, Advanced Key-value cache and store. It is often referred to as adata structure server since keys can contain strings, hashes, lists, sets, sorted set S, bitmaps andhyperloglogs.
Redis is an open source, BSD licensed, advanced " key-value " cache with storage . It is often referred to as a data structure server because keys can be strings, hash tables, lists, collections, ordered collections, bitmaps, and hyperloglogs.
Introduction to Redis outlines the key features and capabilities of Redis:
- Atomic Operations (All commands are atomic operations )
- in-memory DataSet (All data is put in memory )
- Keys with limited time to live
- LRU Cache
- Persistence of (rdb-memory Snapshot | Mirror, aof-append each command to the log)
- Master-Slave asynchronous replication
- sentinel- automatic failover
- Transaction
- Publish/Subscribe
- Lua script
- Recommended use of Linux System Deployment
and common command usage scenarios :
- Increase the value in a hash table (a counter or property of a different dimension)
- Presses an element into a list (message list, queue)
- Get the highest ranked members from an ordered set (top N, hotspot real-time news, hotspot search)
Reference
- Redis command Chinese version, huangz students ' translation
"Hands-on practice"
Practice Goal: Explore highly reliable and scalable distributed Redis cache scenarios
In the practice of the process has not understood the place, will go to see documentation have not I want the East ~
The steps to compile and install from the Redis source code are as follows:
1. Download the latest stable version from download and unzip it
Linux Code
- $ wget http://download.redis.io/releases/redis-2.8.17.tar.gz
- $ TAR-XZF redis-2.8.17.tar.gz
2. After extracting the files, be sure to carefully read the INSTALL and README (redis-2.8.17) under the release file (there are some important information waiting for you to understand, can save you a lot of time in the future Oh! You know ~ ^_^)
3. Follow the steps in the README to build Redis, run Redis, play Redis, install Redis
3.1 Building Redis (be sure to run tests on the server to make sure all commands are available)
Linux Code
- $ CD redis-2.8.17
- $ make
- $ make Test
When building, I encountered an error that prompted the "missing C + + compiler" and would prompt for an available installation package ("sudo apt-get install g++").
3.2 Running a Redis server
Linux Code
- $ src/redis-server
3.3 Playing the Redis client
Linux Code
- $ src/redis-cli
- Redis> set Foo Bar
- Ok
- Redis> get foo
- "Bar"
3.4 Installing the Redis service
Linux Code
- $ sudo make install
4. If you use utils/install_server.sh to generate initialization scripts , configuration Files , install and start Services , you can significantly save time on configuration. But before you use it, take a look at its implementation (note: The service is already part of the system and will start automatically when the system restarts!) )
Linux Code
- $ sudo sh install_server.sh
5. Before you modify the default configuration properties, browse redis.conf. To modify some of the default configuration properties, refer to Redis configuration for more detailed information on documentation's administration topics
6. "Redis as an LRU cache", Redis as a configuration reference for LRU caches (content is valuable!) )
redis.conf Code
- MaxClients 65536
- MaxMemory 128MB
- Maxmemory-policy ALLKEYS-LRU
- Maxmemory-samples 10
- # comment out all the trigger rules for the RDB
- #save 900 1
- #save 300 10
- #save 60 10000
7. "Master-slave" master-slave configuration changes, please refer to the south of the complete Redis springside4 "Appendix 1: Redis.conf Default configuration Modification"
redis.conf Code
- Daemonize Yes
8. Once the relevant properties in redis.conf have been modified, the utils/install_server.sh script can be executed.
9. Using the sudo netstat -anp | grep Redis "To confirm that all Redis services have been successfully started
At this point, all Redis services are started.
Redis Service Rapid Deployment