This article is for notes only. Common cache tools include local cache, distributed cache, and multi-level cache.

The local cache

Local caching, where data is cached on the application server, provides the best performance, but user-specific data, such as login credentials, cannot be used on distributed systems. Common cache tools include Ehcache, Guava, Caffeine, etc. By far the best performer is Caffeine.

Caffeine

The core interface of Caffeine is the Cache. The most common implementations are LoadingCache and AsyncLoadingCache.

Distributed cache

Caching data on NoSQL databases is a cross-server solution. The performance is slightly lower than that of local caching, mainly in network overhead. Its common cache tools are MemCache, Redis and so on.

Multistage cache

Local caching, combined with distributed caching, is called multi-level caching. First access level 1 cache (local cache), if you can’t find the data, go to level 2 cache (distributed cache), still can’t hit the cache, directly to the database.

This avoids cache avalanches and improves system availability.