Home >Database >Redis >Can redis be used as a database?

Can redis be used as a database?

藏色散人
藏色散人Original
2019-06-11 11:40:223602browse

Can redis be used as a database?

Whether redis can be used as a database depends on the following conditions:

1: Data volume, after all, memory The database is still limited by the memory capacity, although it can be persisted through redis.

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, you can use redis as a database.

Otherwise, don’t use it as a database.

Whether redis can be used as a database depends on your specific needs:

1. As mentioned above, there are problems with the persistence of redis. If you use aof mode, and fsync always, the performance is lower than mysql. If you like the convenient data structure of redis and do not have high performance requirements, or have high performance requirements but allow a certain degree of data loss, you can use redis as the database.

2. Redis is an in-memory database. When 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 the 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.

Recommended: "Redis Video Tutorial"

The above is the detailed content of Can redis be used as a 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
Previous article:Is redis atomic?Next article:Is redis atomic?