Viewing Runtime Caches
Problem
You want to enumerate a list of content runtime caches created by Connect. For more information, see the Runtime Caches section of the Admin Guide.
Solution
Call Connect’s API using the SDK. The API returns a JSON response that can be easily transformed into a DataFrame.
from posit import connect
as pl
imports polars
= connect.Client()
client
= client.get("/v1/system/caches/runtime")
response = pl.DataFrame(response.json()["caches"]) caches_df
The data includes information on the language and version of the cache. For Connect servers using off-host execution, the image_name
column includes the name of the execution image. The name Local
indicates that the cache is for local execution mode.
>>> import polars as pl
>>> pl.DataFrame(caches_df)
23, 3)
shape: (
┌──────────┬─────────┬────────────┐
│ language ┆ version ┆ image_name │--- ┆ --- ┆ --- │
│ str ┆ str ┆ str │
│
╞══════════╪═════════╪════════════╡3.0.2 ┆ Local │
│ R ┆ 3.1.0 ┆ Local │
│ R ┆ 3.1.2 ┆ Local │
│ R ┆ 3.1.3 ┆ Local │
│ R ┆ 3.2.0 ┆ Local │
│ R ┆
│ … ┆ … ┆ … │3.10.10 ┆ Local │
│ Python ┆ 3.11.3 ┆ Local │
│ Python ┆ 3.7.6 ┆ Local │
│ Python ┆ 3.8.1 ┆ Local │
│ Python ┆ 3.9.7 ┆ Local │
│ Python ┆ └──────────┴─────────┴────────────┘
Call Connect’s runtime caches API using connectapi
and transform the response into a data frame.
library(connectapi)
library(purrr)
<- connect()
client
<- client$GET("/v1/system/caches/runtime")
response <- map_dfr(response$caches, ~.x) caches_df
The data includes information on the language and version of the cache. For Connect servers using off-host execution, the image_name
column includes the name of the execution image. The name Local
indicates that the cache is for local execution mode.
> caches_df
# A tibble: 23 × 3
language version image_name<chr> <chr> <chr>
1 R 3.0.2 Local
2 R 3.1.0 Local
3 R 3.1.2 Local
4 R 3.1.3 Local
5 R 3.2.0 Local
6 R 3.2.1 Local
7 R 3.2.2 Local
8 R 3.3.3 Local
9 R 3.4.0 Local
10 R 3.4.4 Local
# ℹ 13 more rows
# ℹ Use `print(n = ...)` to see more rows