Deleting Runtime Caches
Problem
You want to request the removal of a specified runtime cache.
Solution
Call the DELETE /v1/system/caches/runtime
endpoint.
You must specify the language, version, and image name for the runtime cache you wish to delete. See Viewing Runtime Caches to view runtime caches on your Connect server.
from posit import connect
= "Python"
LANGUAGE = "3.7.6"
VERSION = "Local"
IMAGE_NAME
= connect.Client()
client
= {
instructions "language": LANGUAGE,
"version": VERSION,
"image_name": IMAGE_NAME
}
= client.delete(
response "v1/system/caches/runtime",
=instructions,
json )
Runtime cache deletion can take some time. A successful request indicates that deletion was started, and returns a task object. You can use this task to poll Connect’s tasks API to check the status of the deletion.
>>> response.json()
'language': 'Python',
{'version': '3.7.6',
'image_name': 'Local',
'task_id': 'lFvijYN16kjCoal6'}
Use Connect’s GET /v1/tasks/{id}
endpoint to check the status of a deletion task.
= response.json()["task_id"]
task_id = client.get(f"/v1/tasks/{task_id}") task_status
>>> task_status.json()
'id': 'lFvijYN16kjCoal6',
{'output': ['Deleting runtime cache...', 'Successfully deleted runtime cache'],
'result': None,
'finished': True,
'code': 0,
'error': '',
'last': 2}
This functionality requires connectapi
version 0.4.0 or later.
You must specify the language, version, and image name for the runtime cache you wish to delete. See Viewing Runtime Caches to view runtime caches on your Connect server.
library(connectapi)
<- "R"
LANGUAGE <- "4.3.0"
VERSION <- "Local"
IMAGE_NAME
<- connect()
client
<- connect()
client
<- delete_runtime_cache(
task
client,language = LANGUAGE,
version = VERSION,
image_name = IMAGE_NAME
)
Runtime cache deletion can take some time. A successful request indicates that deletion was started, and returns a task object. You can use the poll_task()
function to check the status of the deletion.
> poll_task(task)
Deleting runtime cache...
Successfully deleted runtime cache:
Posit Connect Task: ER6i7P1B664bt4KW Task ID