Caches (caches)

The caches endpoint provides access to the application’s caches.spring-doc.cn

Retrieving All Caches

To retrieve the application’s caches, make a GET request to /actuator/caches, as shown in the following curl-based example:spring-doc.cn

$ curl 'http://localhost:8080/actuator/caches' -i -X GET

The resulting response is similar to the following:spring-doc.cn

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 435

{
  "cacheManagers" : {
    "anotherCacheManager" : {
      "caches" : {
        "countries" : {
          "target" : "java.util.concurrent.ConcurrentHashMap"
        }
      }
    },
    "cacheManager" : {
      "caches" : {
        "cities" : {
          "target" : "java.util.concurrent.ConcurrentHashMap"
        },
        "countries" : {
          "target" : "java.util.concurrent.ConcurrentHashMap"
        }
      }
    }
  }
}

Response Structure

The response contains details of the application’s caches. The following table describes the structure of the response:spring-doc.cn

Path Type Description

cacheManagersspring-doc.cn

Objectspring-doc.cn

Cache managers keyed by id.spring-doc.cn

cacheManagers.*.cachesspring-doc.cn

Objectspring-doc.cn

Caches in the application context keyed by name.spring-doc.cn

cacheManagers.*.caches.*.targetspring-doc.cn

Stringspring-doc.cn

Fully qualified name of the native cache.spring-doc.cn

Retrieving Caches by Name

To retrieve a cache by name, make a GET request to /actuator/caches/{name}, as shown in the following curl-based example:spring-doc.cn

$ curl 'http://localhost:8080/actuator/caches/cities' -i -X GET

The preceding example retrieves information about the cache named cities. The resulting response is similar to the following:spring-doc.cn

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 113

{
  "target" : "java.util.concurrent.ConcurrentHashMap",
  "name" : "cities",
  "cacheManager" : "cacheManager"
}

Query Parameters

If the requested name is specific enough to identify a single cache, no extra parameter is required. Otherwise, the cacheManager must be specified. The following table shows the supported query parameters:spring-doc.cn

Parameter Description

cacheManagerspring-doc.cn

Name of the cacheManager to qualify the cache. May be omitted if the cache name is unique.spring-doc.cn

Response Structure

The response contains details of the requested cache. The following table describes the structure of the response:spring-doc.cn

Path Type Description

namespring-doc.cn

Stringspring-doc.cn

Cache name.spring-doc.cn

cacheManagerspring-doc.cn

Stringspring-doc.cn

Cache manager name.spring-doc.cn

targetspring-doc.cn

Stringspring-doc.cn

Fully qualified name of the native cache.spring-doc.cn

Evict All Caches

To clear all available caches, make a DELETE request to /actuator/caches as shown in the following curl-based example:spring-doc.cn

$ curl 'http://localhost:8080/actuator/caches' -i -X DELETE

Evict a Cache by Name

To evict a particular cache, make a DELETE request to /actuator/caches/{name} as shown in the following curl-based example:spring-doc.cn

$ curl 'http://localhost:8080/actuator/caches/countries?cacheManager=anotherCacheManager' -i -X DELETE \
    -H 'Content-Type: application/x-www-form-urlencoded'
As there are two caches named countries, the cacheManager has to be provided to specify which Cache should be cleared.

Request Structure

If the requested name is specific enough to identify a single cache, no extra parameter is required. Otherwise, the cacheManager must be specified. The following table shows the supported query parameters:spring-doc.cn

Parameter Description

cacheManagerspring-doc.cn

Name of the cacheManager to qualify the cache. May be omitted if the cache name is unique.spring-doc.cn