Redis 4 questions

Time:2021-9-26
  1. Why is redis single thread fast?

1) . pure memory operation
2) . non blocking IO multiplexing
3) . single thread avoids frequent context switching

  1. 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

  1. 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.

  1. LruCacheLruCache<K,V> extends LinkedHashMap

1) . constructor true
2) . member variable private int cash_ SIZE
3). removeEldestEntry->return size()>CASH_SIZE

Recommended Today

Supervisor

Supervisor [note] Supervisor – H view supervisor command help Supervisorctl – H view supervisorctl command help Supervisorctl help view the action command of supervisorctl Supervisorctl help any action to view the use of this action 1. Introduction Supervisor is a process control system. Generally speaking, it can monitor your process. If the process exits abnormally, […]