Open MercatoDocsSearch docsAPI reference

CLI

mercato configs cache

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.

Usage

# 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

Commands

CommandWhat it doesTypical use
statsShows CRUD/widget cache segments for the selected scope.Verify what is cached before deleting anything.
purge --allClears 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
structuralAlias for purging nav:* across the chosen scopes.Run after enabling/disabling modules or changing pages/sidebar navigation.

Scope Flags

FlagMeaningNotes
--tenant <tenantId>Operate inside one tenant cache scope.Best for tenant-local navigation or CRUD caches.
--globalOperate only on the global cache scope.Useful for global metadata/config caches.
--all-tenantsIterate 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 Runs and JSON Output

Example:

yarn mercato configs cache purge --pattern 'nav:*' --all-tenants --dry-run --json

Structural Change Workflow

Use the structural shortcut any time the generated app chrome can become stale:

Recommended 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

The admin sidebar no longer needs a purge to survive a deploy

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.

Notes

For internals, see the cache CLI architecture page.

Previous: mercato auth sync-role-acls · Next: mercato customer_accounts sync-customer-role-acls