1.mongodb
(1) is a document-type non-relational database, uses the bson structure. The advantage is that the query function is relatively powerful and it can store massive data. The disadvantage is thatComparison consumes memory.
(2) Generally can be used to store semi-structured data such as comments, and supports secondary indexing. Suitable for storing json type data that does not change frequently.
(3) Example:
a. Website data: very suitable for real-time insertion, update, and query;
b. Cache: The persistent cache layer it builds can avoid overloading the underlying data sources;
c. Used for storage of objects and JSON data: Mongo’s BSON data format is very suitable for storage and query of documented formats;
d.High scalability scenarios: Mongo is very suitable for databases consisting of dozens or hundreds of servers;
e. Not suitable for banking or accounting systems;
f. Common scenarios
2.redis
(1) It is an in-memory database. The data is stored in the memory and directly accessed through tcp. The advantage isHigh read and write performance span>.
(2)redis is a memory KV database (key-value storage database, its data is based on key-value pairs Organize, index, and store according to the situation), does not support secondary index, supports list, set, etc.
Data format. Suitable for storing global variables,Suitable for business scenarios with more reading and less writing. Verysuitable fordoingSlowSave.
(3) Example: (Statistics)
For example, WeChat token is refreshed every two hours, so it is more suitable to use redis for storage, and it is more convenient to read; Online game rankings; after the timer reaches a certain time, the relevant advertising will be displayedReports; sorted byusersvotes and time, updated New News; Statistics
How many specific users have accessed a specific resource during a certain period of time, and statistics of which specific users have accessed a certain articleChapter;
(4) Redis can replace memcached, allowing your cache to change from being able to only store data to being able to update data.
3.memcachedYes In-memory database can be clustered and use multiple cores. Redis can replace memcached.