PgBeam Docs
Projects

Update cache rule

PUT
/v1/projects/{project_id}/databases/{database_id}/cache-rules/{query_hash}

Enable or disable caching for a specific query shape, with optional TTL and SWR overrides. Requires the query to exist in the cache rules.

Authorization

AuthorizationBearer <token>

JWT issued by Better Auth. Verified via JWKS.

In: header

Path Parameters

project_id*string

Unique project identifier (prefixed, e.g. prj_xxx).

database_id*string

Unique database identifier (prefixed, e.g. db_xxx).

query_hash*string

xxhash64 hex of the normalized SQL.

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Request body for updating cache behavior of a query shape.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

curl -X PUT "https://example.com/v1/projects/string/databases/string/cache-rules/stringstringstri" \  -H "Content-Type: application/json" \  -d '{    "cache_enabled": true  }'
{  "entry": {    "query_hash": "a1b2c3d4e5f60718",    "normalized_sql": "SELECT * FROM users WHERE id = $1",    "query_type": "read",    "cache_enabled": true,    "cache_ttl_seconds": 300,    "cache_swr_seconds": 60,    "call_count": 0,    "avg_latency_ms": 0.1,    "p95_latency_ms": 0.1,    "avg_response_bytes": 0,    "stability_rate": 0.1,    "recommendation": "great",    "first_seen_at": "2019-08-24T14:15:22Z",    "last_seen_at": "2019-08-24T14:15:22Z"  }}
{  "error": {    "code": "string",    "message": "string"  }}
{  "error": {    "code": "string",    "message": "string"  }}
{  "error": {    "code": "string",    "message": "string"  }}
{  "error": {    "code": "string",    "message": "string"  }}
{  "error": {    "code": "string",    "message": "string"  }}