abc

package
v0.2.56 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 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 (
	PageCachePrefix = "gincontrib.page.cache"
	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 {
	// Get retrieves an item from the cache. Returns the item or nil, and a bool indicating
	// whether the key was found.
	Get(key string, value interface{}) error

	// Set sets an item to the cache, replacing any existing item.
	Set(key string, value interface{}, expire time.Duration) 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

	// 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

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

	// Increment increments a real number, and returns error if the value is not real
	Increment(key string, data int64) (int64, error)

	// Decrement decrements a real number, and returns error if the value is not real
	Decrement(key string, data int64) (int64, error)

	// Flush seletes all items from the cache.
	Flush() error

	// Expire a key
	Expire(key string, expire time.Duration) (bool, error)
}

CacheStore 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