table of Contents
Solution (e-commerce scenario)
Introduction to Redis
- Problem phenomenon:
- Mass users
- High concurrency
- The culprit-relational database
- Performance bottleneck: low disk IO performance
- Expansion bottleneck: complex data relationship, poor scalability, inconvenient for large-scale clusters
- Solutions
Nosql
- NoSQL: that is, Not-Only SQL (refers to non-relational database), as a complement to relational database .
- Role: To deal with data processing problems based on massive users and massive data.
feature
- Scalable
- High performance under large data volume
- Flexible data model
- High availability
Common Nosql database
- Redis
- memcache
- HBase
- MongoDB
Solution (e-commerce scenario)
Redis
- Concept: the Redis ( REs Mote the DI ctionary S erver) is an open source development language C performance of key ( Key-value ) database.
- Features :
- There is no necessary relationship between data
- Single-threaded mechanism for internal work
- Persistence support . Data disaster recovery is possible
- High performance . Officially provided test data, 50 concurrent executions of 100,000 requests, the read speed is 110,000 times/s, and the write speed is 81,000 times/s.
- Multiple data type support
String type string List type list Hash type hash Collection type set Ordered collection type sorted_set
Redis application
- Accelerate the query of hot data (main scenarios) , such as hot products, hot news, hot information, promotion and other high-traffic information
- Task queue , such as seckill, panic buying, queue for ticket purchase, etc.
Real-time information query , such as rankings, visit statistics of various websites, bus arrival information, online information (chat rooms, websites), equipment signals, etc.
- Timeliness information control , such as verification code control, voting control, etc.
- Distributed data sharing , such as session separation in a distributed cluster architecture
- message queue
- Distributed lock
Install Redis (windows version)
- Windows version:
- Download link: https://github.com/MSOpenTech/redis/tags
- Core files:
redis-server.exe Server start command redis-cli.exe Command line client redis.windows.conf redis Core configuration file redis-benchmark.exe Performance testing tools redis-check-aof.exe AOF File repair tool redis-check-dump.exe RDB File inspection tool (snapshot persistent file)
The basic operation of Redis
Information added
- Function: set key and value data
set key value
- Information query
- Function: Query the corresponding value according to the key, if it does not exist, return empty (nil)
get key
- Clear screen information
- Function: Clear the information on the screen
clear
- Exit client command line mode
- Function: Exit the client
quit exit
- help
- Function: Get command help file, get all command information names in the group
help 命令名称 help @组名
- [Note]: Refer to the Dark Horse Redis tutorial