MySQL 官方文档:
http://dev.mysql.com/doc/refman/5.7/en/memory-storage-engine.htmlThe MEMORY storage engine (formerly known as HEAP) creates special-purpose tables with contents that are stored in memory. Because the data is vulnerable to crashes, hardware issues, or power outages, only use these tables as temporary work areas or read-only caches for data pulled from other tables.
特点:断电 /异常 /崩溃,你存进去的数据就没啦
..............
典型应用
A typical use case for the MEMORY engine involves these characteristics:
Operations involving transient, non-critical data such as session management or caching. When the MySQL server halts or restarts, the data in MEMORY tables is lost.
存放不重要的数据。
In-memory storage for fast access and low latency. Data volume can fit entirely in memory without causing the operating system to swap out virtual memory pages.
快速,低延迟读数据
A read-only or read-mostly data access pattern (limited updates).
只读数据。
总结:数据容易丢失, insert/update 性能不佳,写入锁表,不如 InnoDB ,读取性能貌似比 Redis 快一丢丢。
~~~~~~~~~
Redis :
http://stackoverflow.com/questions/7888880/what-is-redis-and-what-do-i-use-it-for特点: NoSQL (之 key-value 型),数据出现异常不会丢失,支持数据类型多,跨进程跨程序跨服务器共享数据方便快捷。写数据的速度比 MySQL 的 memory 引擎快多了。
单单从性能上说,和在 RamDisk 上的 InnoDB 引擎速度差不多。
不过还是觉得, RDBMS 和 NoSQL 哪个更适合你的项目更重要一些。
MySQL 的 memory 真的很少用,真遇到了读的频繁,写入特别少,数据还不怎么重要的情况可以一试。