Redis breakdown cache, the cache penetrate cache avalanche

Cache breakdown

Breakdown cache, the data refers to a database query must not exist, cache does not exist, directly to the database request.

Avoidance scheme

  1. The results of the query is empty. Add a cache
  2. The key must not exist to filter

Cache penetration

Cache penetration, refers to a hot spot to access the data in an instant failure, is complicated by the large centralized access, direct requests to the database.

Avoidance scheme

  1. Achieved by threaded locking or write queue, reading the first cache, no further database check cached

Cache avalanche

Cache avalanche, refers to the cache focus expire at a certain time period, direct requests to the database.

Avoidance scheme

  1. The same cache penetration, practical locking strategy
  2. Preheat data, updating the cache before an impending avalanche, triggered manually update the cache load, and set different expiration time
  3. Double the cache, a short-term caching, caching a long-term, short-term priority access cache
  4. Set the cache never expires
Published 211 original articles · won praise 68 · views 180 000 +

Guess you like

Origin blog.csdn.net/weixin_42078760/article/details/104077889