终结点提供对应用程序缓存的访问。cachesSpring中文文档

检索所有缓存

若要检索应用程序的缓存,请向 发出请求,如以下基于 curl 的示例所示:GET/actuator/cachesSpring中文文档

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

生成的响应类似于以下内容:Spring中文文档

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"
        }
      }
    }
  }
}

响应结构

响应包含应用程序缓存的详细信息。 下表描述了响应的结构:Spring中文文档

路径 类型 描述

cacheManagersSpring中文文档

ObjectSpring中文文档

按 id 键控的缓存管理器。Spring中文文档

cacheManagers.*.cachesSpring中文文档

ObjectSpring中文文档

应用程序上下文中的缓存按名称键控。Spring中文文档

cacheManagers.*.caches.*.targetSpring中文文档

StringSpring中文文档

本机缓存的完全限定名称。Spring中文文档

路径 类型 描述

cacheManagersSpring中文文档

ObjectSpring中文文档

按 id 键控的缓存管理器。Spring中文文档

cacheManagers.*.cachesSpring中文文档

ObjectSpring中文文档

应用程序上下文中的缓存按名称键控。Spring中文文档

cacheManagers.*.caches.*.targetSpring中文文档

StringSpring中文文档

本机缓存的完全限定名称。Spring中文文档

按名称检索缓存

要按名称检索缓存,请向 发出请求,如以下基于 curl 的示例所示:GET/actuator/caches/{name}Spring中文文档

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

前面的示例检索有关名为 的缓存的信息。 生成的响应类似于以下内容:citiesSpring中文文档

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"
}

查询参数

如果请求的名称足够具体,可以标识单个缓存,则不需要额外的参数。 否则,必须指定。 下表显示了支持的查询参数:cacheManagerSpring中文文档

参数 描述

cacheManagerSpring中文文档

用于限定缓存的 cacheManager 的名称。如果缓存名称是唯一的,则可以省略。Spring中文文档

响应结构

响应包含请求的缓存的详细信息。 下表描述了响应的结构:Spring中文文档

路径 类型 描述

nameSpring中文文档

StringSpring中文文档

缓存名称。Spring中文文档

cacheManagerSpring中文文档

StringSpring中文文档

缓存管理器名称。Spring中文文档

targetSpring中文文档

StringSpring中文文档

本机缓存的完全限定名称。Spring中文文档

参数 描述

cacheManagerSpring中文文档

用于限定缓存的 cacheManager 的名称。如果缓存名称是唯一的,则可以省略。Spring中文文档

路径 类型 描述

nameSpring中文文档

StringSpring中文文档

缓存名称。Spring中文文档

cacheManagerSpring中文文档

StringSpring中文文档

缓存管理器名称。Spring中文文档

targetSpring中文文档

StringSpring中文文档

本机缓存的完全限定名称。Spring中文文档

逐出所有缓存

要清除所有可用的缓存,请发出请求,如以下基于 curl 的示例所示:DELETE/actuator/cachesSpring中文文档

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

按名称逐出缓存

若要逐出特定缓存,请向以下基于 curl 的示例中所示发出请求:DELETE/actuator/caches/{name}Spring中文文档

$ curl 'http://localhost:8080/actuator/caches/countries?cacheManager=anotherCacheManager' -i -X DELETE \
    -H 'Content-Type: application/x-www-form-urlencoded'
由于有两个名为 的缓存,因此必须提供 来指定应清除哪个缓存。countriescacheManagerCache

请求结构

如果请求的名称足够具体,可以标识单个缓存,则不需要额外的参数。 否则,必须指定。 下表显示了支持的查询参数:cacheManagerSpring中文文档

参数 描述

cacheManagerSpring中文文档

用于限定缓存的 cacheManager 的名称。如果缓存名称是唯一的,则可以省略。Spring中文文档

由于有两个名为 的缓存,因此必须提供 来指定应清除哪个缓存。countriescacheManagerCache
参数 描述

cacheManagerSpring中文文档

用于限定缓存的 cacheManager 的名称。如果缓存名称是唯一的,则可以省略。Spring中文文档