entry

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// SourceLocal local cache
	SourceLocal int
	// SourceCenter center cache
	SourceCenter
)

Variables

This section is empty.

Functions

func DefaultLocalExpiration added in v0.4.0

func DefaultLocalExpiration() time.Duration

DefaultLocalExpiration returns the default of local expiration.

func KS

func KS(es ...*Entry) map[string]interface{}

KS key value map.

Types

type Entry

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

Entry a cache entry.

func New

func New(setting ...Setting) (*Entry, error)

New generates an entry.

func (*Entry) Data

func (e *Entry) Data() []byte

Data entry data.

func (*Entry) Decode

func (e *Entry) Decode(data []byte) error

Decode decodes an entry.

func (*Entry) EnableLocalCache

func (e *Entry) EnableLocalCache() bool

EnableLocalCache enables the local expiration.

func (*Entry) Encode

func (e *Entry) Encode() error

Encode encodes an entry.

func (*Entry) Exp added in v0.1.2

func (e *Entry) Exp() time.Duration

Exp expiration.

func (*Entry) Key

func (e *Entry) Key() string

Key returns the key.

func (*Entry) LocalExp added in v0.1.2

func (e *Entry) LocalExp() time.Duration

LocalExp local expiration.

func (*Entry) Reset added in v0.4.2

func (e *Entry) Reset()

Reset resets a entry.

func (*Entry) SetSource added in v0.2.0

func (e *Entry) SetSource(s int)

SetSource sets source.

func (*Entry) SetTTL added in v0.2.0

func (e *Entry) SetTTL(ttl float64)

SetTTL sets ttl for an entry.

func (*Entry) SourceCenter added in v0.2.0

func (e *Entry) SourceCenter() bool

SourceCenter reports cache from center.

func (*Entry) SourceLocal added in v0.2.0

func (e *Entry) SourceLocal() bool

SourceLocal reports cache from local.

func (*Entry) TTL added in v0.2.0

func (e *Entry) TTL() float64

TTL 只会返回redis的存活时间,与SourceCenter一起使用。

func (*Entry) Value

func (e *Entry) Value() interface{}

Value entry value.

type Setting added in v0.2.0

type Setting func(e *Entry) error

Setting configures an entry.

func EnableLocalCache added in v0.2.0

func EnableLocalCache() Setting

EnableLocalCache enables local cache.

func WithExpiration added in v0.2.0

func WithExpiration(d time.Duration) Setting

WithExpiration sets the expiration for the key.

func WithKey added in v0.2.0

func WithKey(key string) Setting

WithKey sets the key.

func WithValue added in v0.2.0

func WithValue(value interface{}) Setting

WithValue sets the corresponding value.

Jump to

Keyboard shortcuts

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