Home  >  Article  >  Backend Development  >  Why is the MEMORY engine of mysql not as widely used as redis?

Why is the MEMORY engine of mysql not as widely used as redis?

WBOY
WBOYOriginal
2016-09-02 08:57:051099browse

I see that many people would rather use redis to store data in json than use mysql's MEMORY engine. Is it because of poor performance of this engine or something else? I have observed that some domestic open source projects have basically not used this engine. Why is this?

Reply content:

I see that many people would rather use redis to store data in json than use mysql's MEMORY engine. Is it because of poor performance of this engine or something else? I have observed that some domestic open source projects have basically not used this engine. Why is this?

  1. Many times the data format saved is relatively complex, it is more convenient to save it in KV format and then save it in JSON format, which is easy to parse

  2. In terms of reliability, redis is better - MySQL's Memory table will lose data after a power outage, but redis is better

First of all: redis is several orders of magnitude faster than mysql.
So:
1. The amount of data is not too large && The amount of data is frequently accessed, so it is better to put it in redis. The amount of data here can refer to the memory size of the redis server. If the amount of data is smaller than the memory size of the redis server, you can consider putting it into redis.

2.Redis access is simpler than mysql.

Let’s first understand MySQL’s Memory engine

<code>http://dev.mysql.com/doc/refman/5.7/en/memory-storage-engine.html
</code>

Look at how many Unsupport there are.

Back to the comparison with Redis, let’s talk about three points

  1. Mysql’s Memory engine does not support expire_date. Do I have to delete it manually?

  2. Before storing data, I have to create a table. What if my data is not in rows and columns, but is unordered?

  3. Are you returning a JSON string to the front end, or a Model class that you took out from the database and serialized? Then why don't I just take a JSON string from Redis and return it directly.

Of course Mysql's Memory engine can also do the above, but the pain index has increased a lot, indicating that it is not very suitable for the above scenarios. You can't use scissors to chop wood, right? Although it can be cut down.

As for the comparison of deeper atomicity, 0 - 0, I don’t think it’s time to discuss the appearance of this thing, because you will compare the sweetness with bitter melon and apple?

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