Difference between dynamic cache and static cache in java

We sought to develop a caching mechanism and came across terms such as dynamic cache and static cache. What is dynamic cache and static cache? Can someone help me figure out an example regarding Java?

+4
source share
2 answers

Static cache and dynamic cache are cache concepts and have almost no relation to any language. There are usually two types of searches.

Insecure search: we scan the base table and return output values ​​based on the Lookup condition. If the search condition matches, it returns a value from the Lookup table or cache. And if the search condition is not met, it returns either NULL or the default value. Here's How Uncached Lookup Works

Cached Search . The Integration Service creates a cache whenever the first line in Lookup is processed. After the cache is created, the integration service always queries the cache instead of the lookup table. It saves a lot of time.

The search key can be of different types, such as dynamic cache and static cache

What is a static cache?

  • Read only In the static cache, the integration service cannot update or insert into the cache during conversion processing.
  • A static cache is similar to cached search, in which, after creating a cache, the integration service always requests a cache instead of a lookup table.
  • In the static cache, when the Lookup condition is true, the return value from the lookup table returns Null or Default.

What is a dynamic cache?

  • Read / write . In the dynamic cache, we can insert or update lines in the cache when passing lines.
  • The Integration Service dynamically inserts or updates data in the search cache and passes data to the target.
  • The dynamic cache is synchronized with the target.
+6
source

In short, the static cache is just the read cache, and the dynamic cache is read and write. Examples of using

Static: when the program starts, we load some reference data from the DB table into the cache once. Now our cache returns data by key, and does not make queries to the database.

Dynamic: we have a DAO with a cache. At getStaffById, we first look at the cache, and if it returns there; otherwise read it from the database, put it in the cache and return it. When deleting / updating, we delete / update both in the cache and in the database.

+2
source

All Articles