SDWeb (Image Cache Architecture Design)
optimization
Reduce the amount of tasks
- No need after caching
Transfer tasks
- More sub-threading operations
- What did your task do
- What did the underlying system do
How to cancel an unloaded picture
How to remove duplicates when loading a picture at the same time
Loading process
First load
-
Network operation (download)
-
Save local
- Load picture
-
Second load
- Take local
bitmap
- A bitmap format for operations in threads
Class composition
Manager
-
Multi-level caching strategy
-
RAM
-
Disk
-
Network download
- time consuming
- Flow loss
-
Find process
-
Find start
-
Memory hit
-
YES
-
NO
-
Disk hit
-
YES
-
NO
-
Network download
- End
-
-
-
-
-
important point
How to read and write pictures?
- Use the URL of the picture as the key
- Encrypt the URL of the picture after MD5 (safe)
- Use the one-way HASH value of the picture URL as the KEY (similar to 2)
Principles of computer organization
- Multi-level cache (improve search efficiency)
- Elimination algorithm (reasonable management space)
Architecture design
Memory design
-
Storage Size
- N small pictures
- N photos
- Big picture N
-
Elimination strategy
-
Queue form
-
LRU
-
the way
-
Check trigger timing/frequency
- Every time you read and write
- When switching between front and back
-
Regular check
-
-
Disadvantage
- space
- time
-
-
Disk design
-
characteristic
- big space
- Low reading efficiency
-
design
- Storage method
- Size limit
- Elimination strategy
Network design
- Maximum concurrent image request
- Request timeout policy (retry once)
- Request priority (task)
Picture decoding
- After disk read
- After the network request returns
- Decoding timing (to be displayed as a premise)
- Different formats of pictures adopt strategic mode to improve the stability of the frame
XMind - Trial Version