|
此版本仍在开发中,尚未视为稳定版。如需最新稳定版本,请使用 Spring Boot 4.0.4! |
缓存(caches)
caches 端点提供对应用程序缓存的访问。
检索所有缓存
要获取应用程序的缓存信息,请向 GET 发起一个 /actuator/caches 请求,如下列基于 curl 的示例所示:
$ curl 'http://localhost:8080/actuator/caches' -i -X GET
生成的响应类似于以下内容:
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"
}
}
}
}
}
按名称检索缓存
要按名称检索缓存,请向 GET 发起一个 /actuator/caches/{name} 请求,如下列基于 curl 的示例所示:
$ curl 'http://localhost:8080/actuator/caches/cities' -i -X GET
前面的示例检索名为 cities 的缓存的相关信息。
返回的响应类似于以下内容:
HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 113
{
"cacheManager" : "cacheManager",
"name" : "cities",
"target" : "java.util.concurrent.ConcurrentHashMap"
}
清除所有缓存
要清除所有可用的缓存,请向 DELETE 发送一个 /actuator/caches 请求,如下列基于 curl 的示例所示:
$ curl 'http://localhost:8080/actuator/caches' -i -X DELETE
按名称驱逐缓存
要清除特定的缓存,请向 DELETE 发送一个 /actuator/caches/{name} 请求,如下列基于 curl 的示例所示:
$ curl 'http://localhost:8080/actuator/caches/countries?cacheManager=anotherCacheManager' -i -X DELETE \
-H 'Content-Type: application/x-www-form-urlencoded'
由于存在两个名为 countries 的缓存,因此必须提供 cacheManager 来指定应清除哪个 Cache。 |