What are the differences between memcached's primary key deletion method and redis?
First, memcached also uses a negative method when deleting an invalid primary key, that is, memcached does not monitor whether the primary key is invalid, but checks whether it has expired only when it accesses the primary key through get. Second, the biggest difference between memcached and redis in the primary key invalidation mechanism is that memcached does not actually Delete the invalid primary key as redis does, but simply recycles the space occupied by the invalid primary key. In this way, when new data is written to the system, memcached will give priority to those spaces with invalid primary keys. If the space for the invalid primary key is used up, memcached can use the LRU mechanism to reclaim the space that is not accessible for a long time. Therefore, memcached does not need to perform periodic deletion operations like redis, this is also determined by the memory management mechanism used by memcached. At the same time, it should be noted that redis can also configure the maxmemory-policy parameter to determine whether to use the LRU mechanism to reclaim memory space when OOM occurs.
Impact of redis primary key failure mechanism on system performance
Through the above introduction to the redis primary key invalidation mechanism, we know that although redis regularly checks the primary key with the expiration time set and deletes the primary key that has expired, however, by limiting the number of databases processed each time, the number of executions of the activeexpirecycle function in one second, the CPU time limit allocated to the activeexpirecycle function, and the percentage of expired primary keys that continue to be deleted, redis has greatly reduced the impact of primary key failure mechanisms on the overall system performance, however, in practical applications, if a large number of primary keys expire in a short period of time, the system's response capability will be reduced. Therefore, this situation should be avoided.
There are two primary key deletion methods for redis:
Passive way: if the primary key is accessed and it becomes invalid, delete it.
The active method periodically selects some expired primary keys from the primary keys with the expiration time set.
Http://redis.io/commands/expire
Http://redis.io/topics/latency
Http://www.cppblog.com/richbirda... 1/11/29/161184 .html
Http://www.cnblogs.com/tangtianf.../05/02/2479315.html
Redis primary key Failure Mechanism