testocache

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package testocache provides caching primitives to be used by external plugins.

By default, it stores cache in a directory "$TWD/.testo_cache", where "$TWD" refers to the "test working directory" (not necessary a project root). Usually, this is a directory where "_test.go" file, which calls this package, is located.

Can be overridden passing "-cache.dir ~/My/Dir" flag to the "go test" command OR (with lesser priority) with environment variable "TESTO_CACHE_DIR".

Caching can also be disabled with flag "-cache.disable" or environtment variable "TESTO_CACHE_DISABLE" (e.g. "=true").

Index

Constants

This section is empty.

Variables

View Source
var ErrDisabled = errors.New("cache is disabled")

ErrDisabled indicates that caching is disabled.

Functions

func Disabled

func Disabled() bool

Disabled returns true if caching is disabled. It's up to the package user to handle disabled state, e.g. do not save objects in cache when this function returns true.

func Get

func Get(key string) ([]byte, error)

Get cached object by the given key.

If cache is disabled (see Disabled), this function returns ErrDisabled.

func Keys

func Keys(pattern string) (keys []string, err error)

Keys returns all glob-matched keys by the given pattern. E.g. "myplugin-prefix-*"

If cache is disabled (see Disabled), this function returns ErrDisabled.

func Remove

func Remove(key string) error

Remove object from cache by the given key.

If cache is disabled (see Disabled), this function returns ErrDisabled.

func Set

func Set(key string, value []byte) error

Set saves value to cache with the given key.

If cache is disabled (see Disabled), this function returns ErrDisabled.

Types

This section is empty.

Jump to

Keyboard shortcuts

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