cache

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoResult       = errors.New("cache return no result")
	ErrObjectNotFound = errors.New("cache object not found")
)

cache find no result

View Source
var (
	RedisConnectTimeout = time.Second * 5
	RedisReadTimeout    = time.Second * 5
	RedisWriteTimeout   = time.Second * 5
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	SaveObject(prefix string, x CacheObjector) error
	SaveFields(prefix string, x CacheObjector, fields map[string]interface{}) error
	LoadObject(prefix string, value interface{}, x CacheObjector) error
	LoadArray(prefix string, ownerId int64, pool *sync.Pool) ([]interface{}, error)
	DeleteObject(prefix string, x CacheObjector) error
	Exit() error
}

func NewCache

func NewCache(ctx *cli.Context) Cache

type CacheObjector

type CacheObjector interface {
	GetObjID() int64
	GetStoreIndex() int64
}

CacheObjector save and load with all structure

type GoRedis

type GoRedis struct {
	utils.WaitGroupWrapper
	// contains filtered or unexported fields
}

func NewGoRedis

func NewGoRedis(ctx *cli.Context) *GoRedis

func (*GoRedis) DeleteObject

func (r *GoRedis) DeleteObject(prefix string, x CacheObjector) error

func (*GoRedis) Exit

func (r *GoRedis) Exit() error

func (*GoRedis) LoadArray

func (r *GoRedis) LoadArray(prefix string, ownerId int64, pool *sync.Pool) ([]interface{}, error)

func (*GoRedis) LoadObject

func (r *GoRedis) LoadObject(prefix string, value interface{}, x CacheObjector) error

func (*GoRedis) SaveFields

func (r *GoRedis) SaveFields(prefix string, x CacheObjector, fields map[string]interface{}) error

func (*GoRedis) SaveObject

func (r *GoRedis) SaveObject(prefix string, x CacheObjector) error

type Redigo

type Redigo struct {
	utils.WaitGroupWrapper

	sync.RWMutex
	// contains filtered or unexported fields
}

func NewRedigo

func NewRedigo(ctx *cli.Context) *Redigo

func (*Redigo) DeleteObject

func (r *Redigo) DeleteObject(prefix string, x CacheObjector) error

func (*Redigo) Exit

func (r *Redigo) Exit() error

func (*Redigo) LoadArray

func (r *Redigo) LoadArray(prefix string, ownerId int64, pool *sync.Pool) ([]interface{}, error)

func (*Redigo) LoadObject

func (r *Redigo) LoadObject(prefix string, value interface{}, x CacheObjector) error

func (*Redigo) SaveFields

func (r *Redigo) SaveFields(prefix string, x CacheObjector, fields map[string]interface{}) error

func (*Redigo) SaveObject

func (r *Redigo) SaveObject(prefix string, x CacheObjector) error

Jump to

Keyboard shortcuts

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