Home  >  Article  >  Database  >  Why not use redis as database

Why not use redis as database

(*-*)浩
(*-*)浩Original
2019-11-21 15:23:543604browse

Why not use redis as database

Whether redis can be used as a database depends on the following conditions:                                                                                                                                                                                                                                                                     #1: The amount of data. After all, in-memory databases are still limited by the memory capacity, although redis can persist it.

2: The structure of the data, whether the relational data structure can be converted into key/value form.

3: Query efficiency, whether range queries, etc. can be converted into efficient hash index queries

Whether redis can be used as a database depends on what you want to store. Data:

If you plan to store some temporary data, the data size is not large and does not require too complex queries, but the performance requirements are relatively high, then you can use redis as a database, otherwise don't use it Use it as a database.

1. As mentioned above,

redis persistence has problems. If you use aof mode and fsync always, the performance is lower than mysql

. If you like redis convenient data If the structure does not have high performance requirements, or the performance requirements are very high, but a certain degree of data loss is allowed, redis can be used as the database.

2. redis is an in-memory database. After the memory is full, the data will not be stored on the hard disk

(VM is unstable and diskstore is not enabled). If your memory is large enough, you can use redis as database.

Redis is a k/v in-memory database, which is suitable for storage of small amounts of data and places with high real-time requirements, but it is not suitable for complete databases. Complete databases basically have a set of detailed solutions. Basically Things that have not been done, such as mysql.

The redis used in the project is used for caching. Set the expiration time and it will be automatically cleared at that time. The database still uses mature solutions such as mysql.

If you insist on using a NoSQL database, I recommend you use Mongodb.

This kind of KV storage does not have the data security guarantee that the database can provide.

So it is more suitable to use it for caching.

Redis is not reliable as a database. Not all data is written back to the disk immediately.

The above is the detailed content of Why not use redis as database. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn