teststore

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrClosed is returned when operations are attempted on a closed Store.
	ErrClosed = errors.New("teststore: store is closed")
)

Functions

This section is empty.

Types

type Store

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

Store is a thread-safe, in-memory implementation of storage.Storage designed for unit testing.

func New

func New() *Store

New creates a new instance of Store.

func (*Store) Close

func (s *Store) Close() error

Close closes the store.

func (*Store) GetMeta

func (s *Store) GetMeta(ctx context.Context, primaryKey string) (*pb.CacheMetadata, bool, error)

GetMeta retrieves the primary index, Vary headers, and soft-purged operational status.

func (*Store) GetVariant

func (s *Store) GetVariant(ctx context.Context, primaryKey, variantKey string) (*pb.VariantInfo, []byte, error)

GetVariant retrieves a specific variant metadata and its body payload.

func (*Store) Purge

func (s *Store) Purge(ctx context.Context, primaryKey string, soft bool) (int64, error)

Purge invalidates the primary metadata and its associated variant body keys.

func (*Store) PurgeAll

func (s *Store) PurgeAll(ctx context.Context) (int64, error)

PurgeAll wipes every entry in the store.

func (*Store) PurgeByPattern

func (s *Store) PurgeByPattern(ctx context.Context, pattern string, soft bool) (int64, error)

PurgeByPattern invalidates all keys matching the given glob pattern within the storage.

func (*Store) PurgeByTag

func (s *Store) PurgeByTag(ctx context.Context, tag string, soft bool) (int64, error)

PurgeByTag invalidates all primary metadata matching a given tag.

func (*Store) Reset

func (s *Store) Reset()

Reset clears all data and resets hooks.

func (*Store) SetClosed

func (s *Store) SetClosed(closed bool)

SetClosed simulates a storage outage / network disconnection.

func (*Store) SetGetMetaHook

func (s *Store) SetGetMetaHook(fn func(ctx context.Context, primaryKey string) (*pb.CacheMetadata, bool, error))

SetGetMetaHook sets a custom hook for GetMeta operations.

func (*Store) SetGetVariantHook

func (s *Store) SetGetVariantHook(fn func(ctx context.Context, primaryKey, variantKey string) (*pb.VariantInfo, []byte, error))

SetGetVariantHook sets a custom hook for GetVariant operations.

func (*Store) SetPurgeByTagHook

func (s *Store) SetPurgeByTagHook(fn func(ctx context.Context, tag string, soft bool) (int64, error))

SetPurgeByTagHook sets a custom hook for PurgeByTag operations.

func (*Store) SetPurgeHook

func (s *Store) SetPurgeHook(fn func(ctx context.Context, primaryKey string, soft bool) (int64, error))

SetPurgeHook sets a custom hook for Purge operations.

func (*Store) SetSetVariantHook

func (s *Store) SetSetVariantHook(fn func(ctx context.Context, primaryKey string, meta *pb.CacheMetadata, variant *pb.VariantInfo, body []byte, ttl time.Duration) error)

SetSetVariantHook sets a custom hook for SetVariant operations.

func (*Store) SetVariant

func (s *Store) SetVariant(ctx context.Context, primaryKey string, meta *pb.CacheMetadata, variant *pb.VariantInfo, body []byte, ttl time.Duration) error

SetVariant atomically records a new or updated variant and its body payload.

Jump to

Keyboard shortcuts

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