Home  >  Article  >  Database  >  Which one is better, memcached or redis?

Which one is better, memcached or redis?

(*-*)浩
(*-*)浩Original
2019-11-30 10:04:582960browse

Speaking of caching frameworks, our most commonly used caching frameworks are memcached and Redis, but there are actually differences between them.

Which one is better, memcached or redis?

The birth of Memcached

In May 2003, Brad Fitzpatrick released the first version of Memcached. At the beginning, it was mainly Born to solve the problem of LiveJournal website access caching, this version of Memcached is written in Perl language. (Recommended study: Redis video tutorial)

After that Anatoly Vorobey rewrote Memcached using C. Now Memcached has been widely used in websites such as YouTube, Reddit, and Facebook.

Speaking of the birth of Memcached, it was mainly due to the storage performance bottleneck of relational databases. Because in the 21st century, with the popularization of personal computers, the number of Internet users in the world has increased sharply, and the number of website visits has also increased.

Because relational databases need to persist data, there will be some processes of writing hard disk IO, so there will be a bottleneck in writing data. In order to solve the problem of slow hard disk IO speed, Memcached stores all data in memory, thus enabling fast data writing and reading.

This is also because Memcached stores data in memory and does not implement persistence. Therefore, when some unexpected situations occur, such as power outages, restarts, machine downtime, etc., all data stored in Memcached will be lost. We only It can be read from the database again and then loaded into Memcached.

In addition, Memcached only supports a single key-value storage, so the data type stored in it is single and cannot adapt to diversified business development.

The birth of Redis

It was precisely because of the above storage problems that Redis was born in May 2009. The creators of Redis saw many problems with Memcached, so they created the Redis caching framework.

In the Redis cache framework, it supports up to 6 types of data storage and provides multiple atomic command operations. And Redis also supports persisting data to local files, so that when an accident occurs, there is no need to read the data from the database again, and the local file can be directly read and restored.

Which one is better?

From the development history of the two caching frameworks, we can know that Redis is an upgraded version of Memcached. Memcached has the basic functions of Redis. All are available.

So many times we use Redis as the preferred caching framework. Of course, Memcached also has some better performance than Redis. For example, when storing a small amount of completely static key-value data, Memcached is better than Redis. Be faster.

But as long as the amount of data is slightly larger, or the data is dynamic, the performance of Memcached will plummet.

So even though Memcached has slight advantages in some aspects, overall Redis is still better than Redis as a caching framework.

For more Redis related technical articles, please visit the Redis Getting Started Tutorial column to learn!

The above is the detailed content of Which one is better, memcached or redis?. 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