table of Contents
redis (Remote DIctionary Server) is written in C language development of key-value single-threaded (thread-safe) of nosql database.
scenes to be used
- Hot data cache.
- token or distributed session
- SMS verification code
- Distributed Lock
- Website counter
- Publish-Subscribe (not recommended)
Supported data types
- String: String
- Hash: Hash
- List: List
- Sorted Set: an ordered collection
- Set: collection
Master-slave replication
Scene: cluster, read and write separation, log backup, high availability
A master multi-slave (only one primary server): the primary server is responsible for both read and write operations, from the server is responsible for read operations.
principle
Configuration
From the server configuration:
#master ip及端口号
slaveof masterIP port
#master 密码
masterauth password
Sentinel mechanism
Scene: redis services heartbeat, failover, monitoring
Endurance of
RDB(Redis Database)
redis default persistent way open to binaries snapshot storage, and is based on a certain time point from time to time perform a persistence operations, real bad.
Suitable for large-scale data persistence and integrity of the data, the situation is less demanding consistency.
AOF(Append Only File)
Record each write operation to the server when the server restart will re-execute these commands to restore the original data, generally every 1s were aof file rewrite operations, data integrity, consistency is relatively high, taking up disk space is relatively large , recovery slower than RDB way.