Introductory Guide to the Redis reading notes

Source: Internet
Author: User
Tags configuration settings lua redis
The project needs, the evil fill up a bit, share for everyone, as an introduction to understand

1. Redis with C development, more than 30,000 lines. Latest Version: 3.2.1
2. Support Type: string (within 512M), hash, list, set, ordered set
3.redis official does not support windows
4. You can limit the maximum amount of memory space occupied by the data, after reaching the space limit, automatically eliminates unwanted keys according to certain rules.
5. All data stored in memory, read and write over 10,000 key values in 1 seconds
6. Redis is a single-threaded model, the single performance has enough friendship, basically will not become a bottleneck. It is more applicable when using advanced data types or persistence features.
The list type key of 7.redis can implement queues, support blocking read, and achieve high performance priority queues
8. Start command: redis-server; Stop command: REDIS-CLI SHUTDOWN; Test connection: Redis-cli Ping
9. Default port: 6379
Redis supports 16 databases by default and connects to the NO. 0 database by default. Select command to replace the database
Config set and config get for configuration settings and fetching
12. Different applications should use different Redis instances to store data. There is no need to worry about Redis instances with multiple memory problems. An empty instance: 1MB
13. Query all keys keys *; Determine existence: Exists bar
Redis Support Services: Multi
15. You can set the key value to the expiration time: expire
16. Each user can now access the number of visits per minute: do a counter. Can be prompted to wait after the value exceeds 1 minutes after expiration
17. Cache implementation: Give the key to generate survival time: First access to the cache, if there is a direct fetch, there is no words, the database to get after the assignment, and set the time to live
$rank = Get Cache:rank
If not $ rank
$rank = XXX
Multi
Set Cache:rank, $rank
Expire cache:rank,7200
Exec
To prevent Redis from consuming too much memory, set the maximum memory MaxMemory and elimination rules Maxmemory-policy
Specific rules include LRU (least recently used)
18. Task Queue implementation: Lpush Rpop
Redis and clients use TCP connections and support pipelines
Redis script: Lua language: Atomic operation, high efficiency, reuse
REDIS-CLI--eval/path/xxx.lua Parameters
Lua language: Efficient lightweight scripting language, "Angry Birds" implementation
Redis to JSON support: Cjson Library, Messagepack support: Cmsgpack Library
redis3.0 above with cluster function: To spread the keys in the database to different nodes
AoF mode (append only file) is not turned on by default, and the execution of each command will be persisted to the hard drive AoF file (plain text).
25. There is a replication function, you can achieve multiple server data synchronization: Master-Slave synchronization: The main database: Read and write, from the database: reading. 1 Lord more from.
You only need to add the slaveof primary database IP primary database port from the database configuration file
26. Master-Slave start: redis-server--port 6380--slaveof 127.0.0.1 6379---------to realize Redis read and write separation
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.