Much of the online introduction to the memcached and Redis differences is that Redis is more of a topic than the data types supported by memcached, and the performance ratio is very small, and I'm doing a performance test for both.
The test content is as follows:
Both add 50,000 key-value, and value is a string, the test script is PHP and the system is a dual-core processor.
Add time-consuming:
Memcached: The first time takes 18 seconds, followed by a repeat load of 10 times, averaging 4.7 seconds. Memory consumption: 47M 32
Redis: The first time takes 19 seconds, followed by a repeat load of 10 times, averaging 4.8 seconds. Memory consumption: 54M
Data statistics for 50,000 keys are time consuming:
Memcached: Average 1.2 seconds
Redis: 1.5 seconds on average
The difference between the two performance is not very large, memcached slightly higher.
For key-value storage, the value of memcached, in addition to supporting strings, can also be stored directly in the array, directly storing the array to write code conveniently, but the memory and time consuming than storing the string is significantly time consuming.
$arr = [
' A ' = ' 1 ',
' B ' = ' 2 ',
' C ' = ' 3 ',
...
];
$cache->set (' Key0 ', Json_encode ($arr)); Storing strings
$cache->set (' Key0 ', $arr); Storing arrays
Memcached and Redis performance test comparison