CLI
Start with the cache scope you want to inspect. A segment, tag or specific key lets you narrow a purge before invalidating a wider set of entries.
yarn mercato configs cache is the operator-facing cache tool for Open Mercato. It exposes the same CRUD/widget segment view as the Backend → Configuration → Cache admin page and adds lower-level purge modes for tags, exact keys, identifier tokens, and key patterns.
The command is discovered through the generated CLI registry rather than being hard-coded into the root binary. For the full pipeline, see Generator architecture.
# Show tenant-scoped CRUD/widget cache statistics
yarn mercato configs cache stats --tenant <tenantId>
# Purge everything in one scope
yarn mercato configs cache purge --all --tenant <tenantId>
# Purge one CRUD/widget segment
yarn mercato configs cache purge --segment admin-nav --tenant <tenantId>
# Purge by cache tag, exact key, identifier token, or glob pattern
yarn mercato configs cache purge --tag nav:sidebar:user:<userId> --tenant <tenantId>
yarn mercato configs cache purge --key <exact-key> --tenant <tenantId>
yarn mercato configs cache purge --id <userId> --tenant <tenantId>
yarn mercato configs cache purge --pattern 'nav:*' --all-tenants
# Recommended structural cleanup after module/page/sidebar changes
yarn mercato configs cache structural --all-tenants
| Command | What it does | Typical use |
|---|---|---|
stats | Shows CRUD/widget cache segments for the selected scope. | Verify what is cached before deleting anything. |
purge --all | Clears every cache key in the selected scope. | Emergency cleanup or cold-reset of one tenant/global scope. |
purge --segment <segment> | Deletes only one CRUD/widget cache segment. | Match the admin page's "Purge segment" behavior. |
purge --tag <tag1,tag2> | Deletes keys attached to one or more cache tags. | Clear RBAC, sidebar, or module-level tag groups. |
purge --key <key1,key2> | Deletes exact cache keys. | Surgical cleanup when you already know the key names. |
purge --id <token1,token2> | Deletes every key whose name contains one of the supplied tokens. | Clean user/entity-specific nav cache without knowing full keys. |
purge --pattern <glob> | Deletes every key matching a glob. | Purge a family such as nav:* or `crud |
structural | Alias for purging nav:* across the chosen scopes. | Run after enabling/disabling modules or changing pages/sidebar navigation. |
| Flag | Meaning | Notes |
|---|---|---|
--tenant <tenantId> | Operate inside one tenant cache scope. | Best for tenant-local navigation or CRUD caches. |
--global | Operate only on the global cache scope. | Useful for global metadata/config caches. |
--all-tenants | Iterate the global scope and every active tenant. | Recommended for structural navigation changes in development. |
If you omit a scope flag, the command uses the global cache scope only.
--dry-run to preview what would be removed without deleting anything.--json to get machine-readable output for automation or CI logs.Example:
yarn mercato configs cache purge --pattern 'nav:*' --all-tenants --dry-run --json
Use the structural shortcut any time the generated app chrome can become stale:
src/modules.tsbackend/* or frontend/* page filesRecommended sequence:
yarn generate
yarn generate already performs a best-effort structural purge after successful generation. Run the explicit cache command again when you want to repeat the purge manually, target a fresh environment, or verify the command output directly:
yarn mercato configs cache structural --all-tenants
nav:sidebar:* keys carry a fingerprint of the enabled module set, each module's declared ACL features, and the backend route manifest – plus a 30-minute TTL. A deployed change to src/modules.ts, to a module's acl.ts, or to a page's nav metadata therefore writes to a new key: old and new processes coexist during a rolling deploy, and no purge – or purge/rollout ordering – is required for the sidebar to reflect the new build.
One input is deliberately outside the fingerprint: a nav icon swap. Icons are React elements whose component identity does not survive serialization, so a deploy that only changes an icon heals on the TTL rather than immediately. Run the structural purge if you need such a change visible at once.
Keep running the structural purge for the rest of the chrome (generated fingerprints, AI agent registries, tenant-scoped nav derivatives), and in development where you want the change visible instantly rather than on the next request.
stats and purge --segment operate on the same CRUD/widget segment model exposed by the admin cache page.purge --tag reports deleted counts, but it cannot list matched keys first because the cache interface does not expose a reverse tag index.purge --id is intentionally fuzzy. It is useful for navigation keys such as nav:sidebar:...:<userId>:..., but it can match multiple keys if the token appears in several names.nav:sidebar:v6:<moduleSurfaceFingerprint>:<locale>:<userId>:<tenantId>:<orgId>:<organizationSelection>. The fingerprint is a build-derived hash, so --key is impractical here – reach for --tag nav:sidebar:user:<userId>, --id <userId>, or --pattern 'nav:*' instead.For internals, see the cache CLI architecture page.
Previous: mercato auth sync-role-acls · Next: mercato customer_accounts sync-customer-role-acls