xcache_abc

package
v0.2.53 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT = time.Duration(0)
	FOREVER = time.Duration(-1)
)

Variables

View Source
var (
	KeyPrefix     = "golug.xcache"
	ErrCacheMiss  = errors.New("cache: key not found")
	ErrNotStored  = errors.New("cache: not stored")
	ErrNotSupport = errors.New("cache: not support")
)

Functions

This section is empty.

Types

type ICache

type ICache interface {
	// Set sets an item to the cache, replacing any existing item.
	Set(key string, value interface{}, expire time.Duration) error
	SetDefault(key string, value interface{}) error

	// Add adds an item to the cache only if an item doesn't already exist for the given
	// key, or if the existing item has expired. Returns an error otherwise.
	Add(key string, value interface{}, expire time.Duration) error
	AddDefault(key string, value interface{}) error

	// Delete removes an item from the cache. Does nothing if the key is not in the cache.
	Delete(key string) error

	// Replace sets a new value for the cache key only if it already exists. Returns an
	// error if it does not.
	Replace(key string, data interface{}, expire time.Duration) error
	ReplaceDefault(key string, data interface{}) error

	// Get retrieves an item from the cache. Returns the item or nil, and a bool indicating
	// whether the key was found.
	Get(key string) (val interface{}, err error)
}

ICache is the interface of a cache backend

Jump to

Keyboard shortcuts

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