---
title: "cache-rules set"
description: "Update cache rule for a query"
canonical: "https://pgbeam.com/docs/cli/projects/cache-rules/set"
last-updated: "2026-09-14T19:37:21.000Z"
---

# cache-rules set

> Update cache rule for a query

URL: https://pgbeam.com/docs/cli/projects/cache-rules/set

Enable or disable caching for a specific query shape, identified by its xxhash64 hash. You can optionally override the TTL (time-to-live) and SWR (stale-while-revalidate) durations. Omitting `--ttl` or `--swr` uses the project-level defaults. Use `pgbeam cache-rules list` to find query hashes.

## Usage

## Options

Option

Description

Required

Default

`<query-hash>`

Query hash (xxhash64 hex) identifying the query shape. Find this via `pgbeam cache-rules list`.

Yes

-

`--database-id <value>`

ID of the database that owns the query

Yes

-

`--enabled <value>`

Whether to enable caching for this query: "true" or "false"

Yes

-

`--ttl <value>`

TTL (time-to-live) override in seconds. Omit to use the project default.

No

-

`--swr <value>`

SWR (stale-while-revalidate) override in seconds. Omit to use the project default.

No

-

All global options (`--token`, `--profile`,
`--project`, `--org`, `--json`, `--no-color`, `--no-trunc`, `--debug`) are
also available on this command.

## Examples

## Output

Prints the updated cache rule showing whether caching is enabled, the TTL, and the SWR duration. With `--json`, returns the full cache rule entry.