Memcached:lru
Reasons for high concurrency support: multiplexed IO (message notification mode), multithreaded mode (number of cores in CPU)
Distributed scenarios:
# normal hash distribution (modulo)
# Consistent hash distribution (0-232 rings)
Redis
LRU: Remove one of the least recently accessed keys from the database
Random elimination algorithm: delete a key from the database randomly
TTL elimination algorithm: delete one of the fastest expired keys from the database
Object counter: Reference to Counter plus 1, reference Invalid-1, 0 Delete, can avoid concurrency problems.
Type of support:
String:
List: Doubly linked list (implements Message queue, head out, tail put)
Set: Unordered collection (poll, no duplicates)
Sorted set: Ordered set (number of top-post orders)
Hash: Hash table, similar to database tables (save user information)
Transaction processing
Persistence:
#内存快照: Depositing binary files
#日志追加
Master-Slave synchronization: No persistence is allowed on primary, slave can
Step: Slave Active connection master;slave SYCN command to Master request synchronization, master Backup to rdb;master the Rdb file to slave;slave empty the database, the RDB import.
Virtual Memory: When physical memory is low.
Clear data:
#定时清除
#用户获取数据时
Memcached and Redis Cache