cache

package
v4.2.6-beta1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache added in v4.0.1

type Cache interface {
	Get(key string, value interface{}) (ok bool)
	GetBytes(key string) (value []byte, ok bool)
	Set(key string, value interface{}) error
	SetWithExpiry(key string, value interface{}, duration time.Duration) error
	Delete(k string) error
	Reset() error
	KeysByPrefix(prefix string) ([]string, error)
	Iterate(it func(key string, val interface{})) error
	Close() error
}

func OpenCache added in v4.0.1

func OpenCache(ctx context.Context, urlstr string) (Cache, error)

OpenCache opens a Cache identified by the URL given. See the URLOpener documentation in driver subpackages for details on supported URL formats, and https://gocloud.dev/concepts/urls for more information.

type Option

type Option func(o *Options)

func WithCleanWindow

func WithCleanWindow(t time.Duration) Option

func WithEviction

func WithEviction(t time.Duration) Option

type Options

type Options struct {
	EvictionTime time.Duration
	CleanWindow  time.Duration
}

type URLMux added in v4.0.1

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

URLMux is a URL opener multiplexer. It matches the scheme of the URLs against a set of registered schemes and calls the opener that matches the URL's scheme. See https://gocloud.dev/concepts/urls/ for more information.

The zero value is a multiplexer with no registered schemes.

func DefaultURLMux added in v4.0.1

func DefaultURLMux() *URLMux

DefaultURLMux returns the URLMux used by OpenTopic and OpenSubscription.

Driver packages can use this to register their TopicURLOpener and/or SubscriptionURLOpener on the mux.

func (*URLMux) OpenCache added in v4.0.1

func (mux *URLMux) OpenCache(ctx context.Context, urlstr string) (Cache, error)

OpenCache calls OpenURL with the URL parsed from urlstr. OpenTopic is safe to call from multiple goroutines.

func (*URLMux) Register added in v4.0.1

func (mux *URLMux) Register(scheme string, opener URLOpener)

Register registers the opener with the given scheme. If an opener already exists for the scheme, Register panics.

func (*URLMux) Schemes added in v4.0.1

func (mux *URLMux) Schemes() []string

Schemes returns a sorted slice of the registered schemes.

func (*URLMux) ValidScheme added in v4.0.1

func (mux *URLMux) ValidScheme(scheme string) bool

ValidScheme returns true if scheme has been registered.

type URLOpener added in v4.0.1

type URLOpener interface {
	OpenURL(ctx context.Context, u *url.URL) (Cache, error)
}

URLOpener represents types than can open Registries based on a URL. The opener must not modify the URL argument. OpenURL must be safe to call from multiple goroutines.

This interface is generally implemented by types in driver packages.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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