spring-framework / org.springframework.test.context.cache / DefaultContextCache

DefaultContextCache

open class DefaultContextCache : ContextCache

Default implementation of the ContextCache API.

Uses a synchronized Map configured with a maximum size and a least recently used (LRU) eviction policy to cache ApplicationContext instances.

The maximum size may be supplied as a constructor argument or set via a system property or Spring property named spring.test.context.cache.maxSize.

Author
Sam Brannen

Author
Juergen Hoeller

Since
2.5

See Also
ContextCacheUtils#retrieveMaxCacheSize()

Constructors

<init>

DefaultContextCache()

Create a new DefaultContextCache using the maximum cache size obtained via ContextCacheUtils#retrieveMaxCacheSize().

DefaultContextCache(maxSize: Int)

Create a new DefaultContextCache using the supplied maximum cache size.

Functions

clear

open fun clear(): Unit

{@inheritDoc}

clearStatistics

open fun clearStatistics(): Unit

{@inheritDoc}

contains

open fun contains(key: MergedContextConfiguration): Boolean

{@inheritDoc}

get

open fun get(key: MergedContextConfiguration): ApplicationContext

{@inheritDoc}

getHitCount

open fun getHitCount(): Int

{@inheritDoc}

getMaxSize

open fun getMaxSize(): Int

Get the maximum size of this cache.

getMissCount

open fun getMissCount(): Int

{@inheritDoc}

getParentContextCount

open fun getParentContextCount(): Int

{@inheritDoc}

logStatistics

open fun logStatistics(): Unit

{@inheritDoc}

put

open fun put(key: MergedContextConfiguration, context: ApplicationContext): Unit

{@inheritDoc}

remove

open fun remove(key: MergedContextConfiguration, hierarchyMode: HierarchyMode): Unit

{@inheritDoc}

reset

open fun reset(): Unit

{@inheritDoc}

size

open fun size(): Int

{@inheritDoc}

toString

open fun toString(): String

Generate a text string containing the implementation type of this cache and its statistics.

The string returned by this method contains all information required for compliance with the contract for #logStatistics().