cache

package
v2.39.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: Apache-2.0 Imports: 1 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 uint 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
}

type DefaultCache

type DefaultCache map[string]bool

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

Jump to

Keyboard shortcuts

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