codec

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2021 License: MIT Imports: 2 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

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

Codec represents an instance of a cache store

func New

func New(store store.StoreInterface) *Codec

New return a new codec instance

func (*Codec) Clear added in v1.0.0

func (c *Codec) Clear() error

Clear resets all codec store data

func (*Codec) Delete added in v0.2.0

func (c *Codec) Delete(key interface{}) error

Delete allows to remove a value for a given key identifier

func (*Codec) Get

func (c *Codec) Get(key interface{}) (interface{}, error)

Get allows to retrieve the value from a given key identifier

func (*Codec) GetStats

func (c *Codec) GetStats() *Stats

GetStats returns some statistics about the current codec

func (*Codec) GetStore

func (c *Codec) GetStore() store.StoreInterface

GetStore returns the store associated to this codec

func (*Codec) GetWithTTL added in v1.1.0

func (c *Codec) GetWithTTL(key interface{}) (interface{}, time.Duration, error)

GetWithTTL allows to retrieve the value from a given key identifier and its corresponding TTL

func (*Codec) Invalidate added in v0.2.0

func (c *Codec) Invalidate(options store.InvalidateOptions) error

Invalidate invalidates some cach items from given options

func (*Codec) Set

func (c *Codec) Set(key interface{}, value interface{}, options *store.Options) error

Set allows to set a value for a given key identifier and also allows to specify an expiration time

type CodecInterface

type CodecInterface interface {
	Get(key interface{}) (interface{}, error)
	GetWithTTL(key interface{}) (interface{}, time.Duration, error)
	Set(key interface{}, value interface{}, options *store.Options) error
	Delete(key interface{}) error
	Invalidate(options store.InvalidateOptions) error
	Clear() error

	GetStore() store.StoreInterface
	GetStats() *Stats
}

CodecInterface represents an instance of a cache codec

type Stats

type Stats struct {
	Hits              int
	Miss              int
	SetSuccess        int
	SetError          int
	DeleteSuccess     int
	DeleteError       int
	InvalidateSuccess int
	InvalidateError   int
	ClearSuccess      int
	ClearError        int
}

Stats allows to returns some statistics of codec usage

Jump to

Keyboard shortcuts

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