cache

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrNil

func ErrNil(err error) bool

func Register

func Register(name string, cacheHandler cacheHandler) error

func Use

func Use(name string) (cacheHandler, error)

Types

type CacheHandler

type CacheHandler interface {
	GetConfig() map[string]interface{}
	Set(key interface{}, value interface{}) error
	Get(key interface{}) (interface{}, error)
	Keys(key interface{}) (interface{}, error)
	Expire(key interface{}, expire int64) error
	Del(key interface{}) (interface{}, error)
	Hset(key interface{}, field interface{}, value interface{}) error
	Hget(key interface{}, field interface{}) (interface{}, error)
	Hgetall(key interface{}) (interface{}, error)
	Exists(key interface{}) (bool, error)
	ScanStruct(src []interface{}, dest interface{}) error
	Sadd(key interface{}, value interface{}) error
}

type Handler

type Handler interface {
	Initiate(ctx context.Context) error
	NewCache(ctx context.Context, name string, config map[string]interface{}) (CacheHandler, error)
	GetCache(name string) (CacheHandler, error)
}

func NewRedisHandler

func NewRedisHandler() Handler

type Instance

type Instance struct {
	Config  *config.Instance
	Utility *utility.Instance
	// contains filtered or unexported fields
}

func NewInstance

func NewInstance() *Instance

func (*Instance) GetCache

func (this *Instance) GetCache(name string) (CacheHandler, error)

func (*Instance) HandlerName

func (this *Instance) HandlerName() string

func (*Instance) Initiate

func (this *Instance) Initiate(ctx context.Context) (newCtx context.Context, err error)

func (*Instance) NewCache

func (this *Instance) NewCache(ctx context.Context, name string) (CacheHandler, error)

func (*Instance) OnRequestShutdown

func (this *Instance) OnRequestShutdown(c *routing.Context) error

func (*Instance) OnRequestStartup

func (this *Instance) OnRequestStartup(c *routing.Context) error

func (*Instance) OnShutdown

func (this *Instance) OnShutdown(ctx context.Context) (context.Context, error)

func (*Instance) OnStartup

func (this *Instance) OnStartup(ctx context.Context) (context.Context, error)

func (*Instance) Use

func (this *Instance) Use(ctx context.Context, handlerName string) error

type RedisHandler

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

func (*RedisHandler) GetCache

func (this *RedisHandler) GetCache(name string) (CacheHandler, error)

func (*RedisHandler) Initiate

func (this *RedisHandler) Initiate(ctx context.Context) error

func (*RedisHandler) NewCache

func (this *RedisHandler) NewCache(ctx context.Context, name string, config map[string]interface{}) (CacheHandler, error)

type RedisPool

type RedisPool struct {
	Host      string
	Port      string
	Password  string
	Database  int
	MaxActive int
	MaxIdle   int
	KeyPrefix string
	Pool      *redis.Pool
}

func (*RedisPool) Del

func (this *RedisPool) Del(key interface{}) (interface{}, error)

func (*RedisPool) Exists

func (this *RedisPool) Exists(key interface{}) (bool, error)

func (*RedisPool) Expire

func (this *RedisPool) Expire(key interface{}, expire int64) error

func (*RedisPool) Get

func (this *RedisPool) Get(key interface{}) (interface{}, error)

func (*RedisPool) GetConfig

func (this *RedisPool) GetConfig() map[string]interface{}

func (*RedisPool) Hget

func (this *RedisPool) Hget(key interface{}, field interface{}) (interface{}, error)

func (*RedisPool) Hgetall

func (this *RedisPool) Hgetall(key interface{}) (interface{}, error)

func (*RedisPool) Hmget

func (this *RedisPool) Hmget(key interface{}, args ...interface{}) (interface{}, error)

func (*RedisPool) Hmset

func (this *RedisPool) Hmset(key interface{}, args ...interface{}) error

func (*RedisPool) Hset

func (this *RedisPool) Hset(key interface{}, field interface{}, value interface{}) error

func (*RedisPool) Keys

func (this *RedisPool) Keys(key interface{}) (interface{}, error)

func (*RedisPool) Sadd

func (this *RedisPool) Sadd(key interface{}, value interface{}) error

func (*RedisPool) ScanStruct

func (this *RedisPool) ScanStruct(src []interface{}, dest interface{}) error

func (*RedisPool) Set

func (this *RedisPool) Set(key interface{}, value interface{}) error

Jump to

Keyboard shortcuts

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