- Why is redis single thread fast?
1) . pure memory operation
2) . non blocking IO multiplexing
3) . single thread avoids frequent context switching
- How does redis delete the cache?
Scheduled deletion + inert deletion
1) . select some keys at random every 100ms – > check the expiration time
2) When querying a key – > check expiration time – > delete when it expires
- Redis memory elimination strategy
1) . noevict do not delete – > error
2) . allkey LRU: the least recently used key
3) . allkey random: random deletion
4) . volatile LRU: LRU in key with expiration time
5) . volatile random: deleted randomly in the with expiration time
6) . volatile TTL: delete the earlier key from the key with expiration time.
- LruCacheLruCache<K,V> extends LinkedHashMap
1) . constructor true
2) . member variable private int cash_ SIZE
3). removeEldestEntry->return size()>CASH_SIZE