Some basic common sense of caching

 1. Basic Concepts

 

1. Cache (cache): From the CPU's primary and secondary caches, the Internet's DNS, to the browser cache, it can be regarded as a cache.

Wikipedia: writes

a store of things that will be required in the future, and can be retrieved rapidly.

(Temporary place to store data (frequently used data), because the cost of fetching the original data is too high, so I can get it faster)

     

 

 

2. Cache hit (left side of the picture below)

When a data element is requested from cache and the elements exists for the given key.

3. Cahe miss (cache miss): Opposite to Cache hit (right below)

 
 

4. Cache algorithm: How to kick out "useless" data when the cache capacity exceeds the preset.

例如:LRU(Least Recently Used) FIFO(First Input First Output)Least Frequently Used(LFU) 等等  

 

5. System-of-Record (real data source): For example, relational databases, other persistent systems, and so on.

   There is also an English book called authority data

 

6. serialization-and-deserialization (serialization and deserialization): you can refer to: serialization and deserialization (written by Meituan engineers, very good article)

    There is also a separate article to analyze it later.

   

 

 

6. Scale Up (vertical expansion) and Scale out (horizontal expansion)

 

  When a donkey pulls a cart, it is not usually a donkey to be strong (there is a limit), but usually a group of donkeys to pull (of course, each individual should not be too bad). 

 

 

 

The same is true for servers, at least for the Internet:

7. Write-through 和 write-behind

 

8. Amalda's Law: used to calculate cache speedup

 

 

2. The type or type of cache

 

1. LocalCache (standalone): such as Ehcache, BigMemory Go

(1) Cached and applied in a JVM.

(2) The caches do not communicate and are independent.

(3) Weak consistency.

 

2. Standalone: 

(1) Cache and application are deployed independently.

(2) The cache can be a single unit. (For example, memcache/redis stand-alone, etc.)

(3) Strong consistency

(4) No high availability and no distribution.

(5) Cross-process, cross-network

 

3. Distributed: such as Redis-Cluster, memcache cluster, etc.

(1) Cache and application are deployed independently.

(2) Multiple instances. (eg memcache/redis, etc.)

(3) Strong consistency or eventual consistency

(4) Support Scale Out and high availability.

(5) Cross-process, cross-network

 

4. Replicated: When data is cached, it is stored in multiple application nodes at the same time, and the events of data replication and invalidation are propagated between each cluster node in a synchronous or asynchronous form. (also weak consistency)

This is not used much.

 

 

3. Data layer access speed: (as a developer, remember these orders of magnitude)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325256313&siteId=291194637