cache

package
v2.89.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSuchKey = errors.New("there's no such key existing in cache")

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Set puts key and value into cache.
	// First parameter for extra should be time.Time object denoting expected survival time.
	// If survival time equals 0 or less, the key will always be survival.
	Set(key string, value bool, extra ...interface{}) error

	// Get returns result for key,
	// If there's no such key existing in cache,
	// ErrNoSuchKey will be returned.
	Get(key string) (bool, error)

	// Delete will remove the specific key in cache.
	// If there's no such key existing in cache,
	// ErrNoSuchKey will be returned.
	Delete(key string) error

	// Clear deletes all the items stored in cache.
	Clear() error
}

func NewDefaultCache added in v2.65.0

func NewDefaultCache() (Cache, error)

func NewSyncCache added in v2.66.0

func NewSyncCache() (Cache, error)

type DefaultCache

type DefaultCache map[string]cacheItem

func (*DefaultCache) Clear

func (c *DefaultCache) Clear() error

func (*DefaultCache) Delete

func (c *DefaultCache) Delete(key string) error

func (*DefaultCache) Get

func (c *DefaultCache) Get(key string) (bool, error)

func (*DefaultCache) Set

func (c *DefaultCache) Set(key string, value bool, extra ...interface{}) error

type SyncCache added in v2.66.0

type SyncCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*SyncCache) Clear added in v2.66.0

func (c *SyncCache) Clear() error

func (*SyncCache) Delete added in v2.66.0

func (c *SyncCache) Delete(key string) error

func (*SyncCache) Get added in v2.66.0

func (c *SyncCache) Get(key string) (bool, error)

func (*SyncCache) Set added in v2.66.0

func (c *SyncCache) Set(key string, value bool, extra ...interface{}) error

Jump to

Keyboard shortcuts

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