console

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package console holds the cache commands.

Four of them, each a value with a Handle and a Command that puts it in a console.Registry. They are here and not in the parent package because a command imports the console, the console imports the cache, and a cache that imported its own commands would be a cycle.

Every command that touches entries takes a --tenant and holds a system grant for it. Flush empties one tenant's slice of one namespace, and a cache:clear that emptied the store would clear every other customer on the way past.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheTableCommand

type CacheTableCommand struct {
	// Directory is where the migration is written. Empty means the working
	// directory's database/migrations, which is where the rest of them live.
	Directory string
}

CacheTableCommand writes the migration for the cache tables.

It writes SQL and not a migration type, because there is no migration type to write against yet: hesape/database is being built in parallel and this command belongs to whoever needs the table today. When it lands, this is the file that changes.

func NewCacheTableCommand

func NewCacheTableCommand(directory string) *CacheTableCommand

NewCacheTableCommand returns the command.

func (*CacheTableCommand) Command

func (c *CacheTableCommand) Command() console.Command

Command is the registry entry for make:cache-table.

func (*CacheTableCommand) Handle

func (c *CacheTableCommand) Handle(_ context.Context, o *console.IO) error

Handle runs the command. It answers the migration MigrationGeneratorCommand::handle() writes for CacheTableCommand.

It refuses to overwrite: a migration that has already run and is rewritten underneath is a schema nobody can reproduce.

type ClearCommand

type ClearCommand struct {
	// contains filtered or unexported fields
}

ClearCommand flushes one tenant's cache.

The tenant is not optional: Flush empties one tenant's slice of one namespace, and a cache:clear that emptied the store would clear every other customer on the way past. In a SaaS that is an outage caused by a support request.

func NewClearCommand

func NewClearCommand(m *cache.CacheManager) *ClearCommand

NewClearCommand returns the command.

func (*ClearCommand) Command

func (c *ClearCommand) Command() console.Command

Command is the registry entry for cache:clear.

func (*ClearCommand) Handle

func (c *ClearCommand) Handle(ctx context.Context, o *console.IO) error

Handle runs the command.

It answers ClearCommand::handle(), including the order: the locks branch comes first and does nothing else, because clearing the locks and clearing the cache are different operations and doing both would release a lock somebody is holding on the way to emptying a cache.

type ForgetCommand

type ForgetCommand struct {
	// contains filtered or unexported fields
}

ForgetCommand removes one key from the cache.

func NewForgetCommand

func NewForgetCommand(m *cache.CacheManager) *ForgetCommand

NewForgetCommand returns the command.

func (*ForgetCommand) Command

func (c *ForgetCommand) Command() console.Command

Command is the registry entry for cache:forget.

func (*ForgetCommand) Handle

func (c *ForgetCommand) Handle(ctx context.Context, o *console.IO) error

Handle runs the command. It answers ForgetCommand::handle().

type PruneStaleTagsCommand

type PruneStaleTagsCommand struct {
	// contains filtered or unexported fields
}

PruneStaleTagsCommand removes the tag entries nothing points at any more.

It is a no-op on every store this package ships, and says so rather than pretending it did something. A tag generation here is an ordinary entry with a ttl, so it prunes itself; the store that keeps a set beside them, and therefore has something to prune, is the RESP one in hesape/redis, a separate module registered through CacheManager.Extend.

func NewPruneStaleTagsCommand

func NewPruneStaleTagsCommand(m *cache.CacheManager) *PruneStaleTagsCommand

NewPruneStaleTagsCommand returns the command.

func (*PruneStaleTagsCommand) Command

func (c *PruneStaleTagsCommand) Command() console.Command

Command is the registry entry for cache:prune-stale-tags.

func (*PruneStaleTagsCommand) Handle

func (c *PruneStaleTagsCommand) Handle(ctx context.Context, o *console.IO) error

Handle runs the command. It answers PruneStaleTagsCommand::handle().

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL