I this time in the use of Redis, feeling quite convenient, but more puzzled in the choice of memory database when the time to choose Redis, when the choice of memcache, and then the following corresponding data, is from the Redis author's argument (StackOverflow above).
You should not care too much about performances. Redis is faster each core with small values, but memcached are able to use multiple cores with a single executable and TCP p ORT without help from the client. Also memcached is faster with the "the" Order of 100k. Redis recently improved a lot about big values (unstable branch) but still the is memcached in the use case. The point here is Is:nor one or the other would likely going to is your bottleneck for the query-per-second they can deliver.
You should care about memory usage. For simple key-value pairs memcached are more memory efficient. If use Redis hashes, Redis are more memory efficient. Depends on the use case.
You are should care about persistence and replication, two features only available in Redis. Even if your goal is to build a cache it helps this after a upgrade or a reboot your data are still.
You are should care about the kind of operations you need. In Redis there are a lot of complex operations, even just considering the "caching use Case", you often can does a lot more in A single operation, without requiring the data to be processed client side (a lot of I/O is sometimes needed). This is operations are often as fast as plain get and SET. So if you don ' t need just get/set but more complex things redis can help a lot (on the "at timeline caching).
A netizen translates as follows [1]:
There is no need to focus too much on performance. Since Redis only uses a single core, and memcached can use multi-core, in comparison, the average redis on each kernel is higher than the memcached performance in storing small data. In more than 100k of data, memcached performance is higher than Redis, although Redis recently in the storage of large data performance optimization, but compared to memcached, or slightly inferior. Having said so much, the conclusion is that no matter which one you use, the number of requests processed per second will not be a bottleneck.
You need to focus on memory usage. For simple data storage such as Key-value, Memcache has a higher memory usage rate. If the hash structure is used, the Redis memory usage will be higher. Of course, these all depend on the specific application scenario.
You need to focus on data persistence and master-slave replication, only Redis has these two features. If your goal is to build a slow upgrade or restart before the data is not lost, then you can only choose Redis.
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/database/extra/
You should be concerned about the operation you need. Redis supports a lot of complex operations, even considering the use of memory, you can often do a lot in a single operation without having to read the data to the client (which requires a lot of IO operations). These complex operations are basically as fast as pure get and post operations, so you don't just need get/set but more operations, Redis can play a big role.
For the choice of the two or to see the specific application scenarios, if the need to cache the data is only key-value such a simple structure, I still use memcache in the project, it is enough stable and reliable. When it comes to storing, sorting, and a series of complex operations, there is no doubt that you choose Redis.
As for the differences between Redis and memcache, here are some relevant statements for the record:
The difference between Redis and Memecache lies in [2]:
1, storage mode:
Memecache all the data in memory, the power will hang off, the data can not exceed the memory size
Redis There are parts on the hard drive, this can guarantee the durability of the data, support the persistence of data (I note: There are snapshots and aof log two ways of persistence, in practical applications, pay special attention to the profile snapshot parameters, or very likely the server is often loaded with dump).
2. Data support type:
Redis is much more than memecache in data support.
3, using the underlying model is different:
The new version of Redis directly builds the VM mechanism itself, because the general system calls the system function, it will waste a certain amount of time to move and request.
4, the operating environment is different:
Redis currently only supports Linux, which eliminates support for other systems, so that it can be better spent on optimizing the system's environment, although Microsoft has a team to write a patch for it later. But not on the trunk.
Personal summary, there is a persistent demand or the data structure and processing have advanced requirements of the application, select Redis, other simple key/value storage, select Memcache.