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
import polars as pl

client = connect.Client()

runtime_caches = client.system.caches.runtime.find()

caches_df = pl.DataFrame(runtime_caches)

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
shape: (23, 3)
┌──────────┬─────────┬────────────┐
│ language ┆ version ┆ image_name │
---------
strstrstr
╞══════════╪═════════╪════════════╡
│ R        ┆ 3.0.2   ┆ Local      │
│ R        ┆ 3.1.0   ┆ Local      │
│ R        ┆ 3.1.2   ┆ Local      │
│ R        ┆ 3.1.3   ┆ Local      │
│ R        ┆ 3.2.0   ┆ Local      │
│ …        ┆ …       ┆ …          │
│ Python   ┆ 3.10.10 ┆ Local      │
│ Python   ┆ 3.11.3  ┆ Local      │
│ Python   ┆ 3.7.6   ┆ Local      │
│ Python   ┆ 3.8.1   ┆ Local      │
│ Python   ┆ 3.9.7   ┆ Local      │
└──────────┴─────────┴────────────┘
Note

This functionality requires connectapi version 0.4.0 or later.

Use the get_runtime_caches() function in connectapi.

library(connectapi)
library(purrr)

client <- connect()
result <- get_runtime_caches(client)

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.

> result
# 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