liveBook · Manning

Cache key

As explained in Testing Spring Boot Applications

A cache key is an identifier derived from configuration values that determines whether a cached test application context can be reused.

A cache key identifies the configuration of a Spring test application context. The Spring TestContext Framework uses it to decide whether an existing ApplicationContext can be reused or a new one must be started. section 3.5.1

The key broadly reflects:

Identical test configurations

Two nested tests using the same @SpringBootTest configuration can share one running context: the first test produces a cache miss, while the second produces a cache hit.

How Testing Spring Boot Applications covers it

How deep it goes
Explains configuration inputs and cache hits, while stopping short of defining the framework’s complete key-generation algorithm.
Examples
Uses identical slow and fast Spring Boot tests plus cache statistics showing one miss followed by a hit.
What it assumes
Assumes Spring Boot test applications and defines how their configuration determines cached ApplicationContext reuse.
What you can do after
Diagnose test-context reuse by enabling Spring TestContext logging and reading cache size, hit, miss, and failure statistics.
How it connects
Connects Spring TestContext Framework, ApplicationContext, Spring Boot tests, profiles, and test application configuration.

Also explained in

Compare how 4 books explain cache key →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Testing Spring Boot Applications. The section links point to the parts of the book it draws on.