Preface
The difference between redis and memcache is often mentioned in interviews. Today we will take a look at the knowledge of redis and memcache
concept
memcached: an open source, high-performance, distributed memory system
redis: an open source, key-value type memory running and supporting persistent NoSQL database.
The two of them have something in common: literally, there are two:
- All open source
- All based on memory
the difference
Some comparison parameters they mentioned on the official website
Comparison parameters | repeat | memcache |
---|---|---|
Types of | Support memory; is a non-relational database | Support memory; key-value key-value pair form |
Data storage type | string;list;set;hash;zset | Text type; binary type |
Additional features | Publish and subscribe; master-slave partition; serialization support | Multi-threaded service support |
Network IO model | Single process mode | Multi-threaded, non-blocking mode |
Endurance | RDB; AOF | not support |
Interview answer
Example:
Both redis and memcache put the database in memory, but memcache can also cache some videos and pictures that redis cannot cache.
Relatively speaking, redis supports more data types than memcache. In addition to the basic key/value, there are also storage of list, set, hash and other data structures.
Another important difference is that in terms of the security of stored data, the data is gone after memcache is down, but redis can be persisted and restored through AOF.
to sum up
For redis and memcache as long as any one appears on your resume, most of them will ask you the difference between them. So be sure to prepare these basic interview questions before the interview.
Nowadays, it is popular to brush questions and brush algorithms in big company interviews, so I often tell you that there are two kinds of interviews, one is prepared, the other is not prepared, but the latter has a higher probability of passing.
Prepared, indicating that you are interested in our company.