storage

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllPurger

type AllPurger interface {
	// PurgeAll deletes every key in the storage engine's configured namespace prefix.
	// Returns the number of primary metadata entries deleted.
	PurgeAll(ctx context.Context) (int64, error)
}

AllPurger is an optional capability interface implemented by storage engines that support a total namespace wipeout (e.g. Redis SCAN prefix* + UNLINK).

Only keys within the engine's configured namespace prefix are affected. All other keys in the same backend instance are preserved.

type PatternPurger

type PatternPurger interface {
	// PurgeByPattern invalidates all keys matching the given glob pattern within the storage namespace.
	// If soft is true, marks all matched entries as stale.
	// If soft is false (hard purge), physically deletes all matched metadata and associated body keys.
	// Returns the number of matching primary metadata entries invalidated.
	PurgeByPattern(ctx context.Context, pattern string, soft bool) (int64, error)
}

PatternPurger is an optional capability interface implemented by storage engines that support glob/pattern-based key invalidation (e.g. Redis SCAN + UNLINK / soft purge).

The pattern syntax follows the backend's native glob syntax:

Implementations must guarantee that only keys belonging to the engine's configured namespace prefix are matched — never keys outside the prefix.

type Storage

type Storage interface {
	// GetMeta retrieves the primary index, Vary headers, and soft-purged operational status for the primary URL key.
	// Returns (nil, false, nil) if the entry does not exist.
	GetMeta(ctx context.Context, primaryKey string) (*pb.CacheMetadata, bool, error)

	// GetVariant retrieves a specific variant metadata and its compressed body payload.
	// Returns (nil, nil, nil) if the variant or body does not exist.
	GetVariant(ctx context.Context, primaryKey, variantKey string) (*pb.VariantInfo, []byte, error)

	// SetVariant atomically records a new or updated variant and its body payload without rewriting the full metadata index.
	SetVariant(ctx context.Context, primaryKey string, meta *pb.CacheMetadata, variant *pb.VariantInfo, body []byte, ttl time.Duration) error

	// Purge invalidates the primary metadata and its associated variant body keys.
	// If soft is true, marks the entry as stale for fallback while preserving payload data.
	// If soft is false (hard purge), physically deletes the metadata and all variant body keys.
	// Returns the number of primary entries purged (1 if found, 0 if not found).
	Purge(ctx context.Context, primaryKey string, soft bool) (int64, error)

	// PurgeByTag invalidates all primary metadata and all associated body keys matching a given tag.
	// Returns the total number of primary entries invalidated.
	PurgeByTag(ctx context.Context, tag string, soft bool) (int64, error)

	// Close cleanly terminates storage connections.
	Close() error
}

Storage defines the decoupled interface for Titip cache storage backends.

Directories

Path Synopsis
redis module
caddy module

Jump to

Keyboard shortcuts

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