cache

package
v0.0.0-...-4f9ff06 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitCacheClientSvc

func InitCacheClientSvc(cacheHost string, cachePort string, cachePassword string)

func InitCacheMemSvc

func InitCacheMemSvc()

func NewRedisClient

func NewRedisClient(hostname, port, password string) (*redis.Client, error)

NewCacheClient return a new instance of cache client

Types

type Client

type Client struct {
	Client *redis.Client
}

func NewSimpleCacheClient

func NewSimpleCacheClient(host, port, password string) (*Client, error)

func (*Client) Del

func (cache *Client) Del(ctx context.Context, key string) error

func (*Client) Expire

func (cache *Client) Expire(ctx context.Context, key string, expiration time.Duration) error

func (*Client) Get

func (cache *Client) Get(ctx context.Context, key string) (interface{}, error)

func (*Client) HDel

func (cache *Client) HDel(ctx context.Context, key string, fields string) error

func (*Client) HGet

func (cache *Client) HGet(ctx context.Context, key string, field string) (string, error)

func (*Client) HGetAll

func (cache *Client) HGetAll(ctx context.Context, key string) map[string]string

func (*Client) HSet

func (cache *Client) HSet(ctx context.Context, key string, values ...interface{}) error

func (*Client) HSetExp

func (cache *Client) HSetExp(ctx context.Context, key string, expiration time.Duration, values ...interface{}) error

func (*Client) HSetNX

func (cache *Client) HSetNX(ctx context.Context, key string, field string, value interface{}, expiration time.Duration) (set bool, err error)

func (*Client) Set

func (cache *Client) Set(ctx context.Context, key string, values interface{}, expiration time.Duration) error

type ClientMem

type ClientMem struct {
	Client *ristretto.Cache
}

func NewCacheMemClient

func NewCacheMemClient() (*ClientMem, error)

func (*ClientMem) Del

func (cache *ClientMem) Del(ctx context.Context, key string) error

func (*ClientMem) Expire

func (cache *ClientMem) Expire(ctx context.Context, key string, expiration time.Duration) error

func (*ClientMem) Get

func (cache *ClientMem) Get(ctx context.Context, key string) (interface{}, error)

func (*ClientMem) HDel

func (cache *ClientMem) HDel(ctx context.Context, key string, fields string) error

func (*ClientMem) HGet

func (cache *ClientMem) HGet(ctx context.Context, key string, field string) (string, error)

func (*ClientMem) HGetAll

func (cache *ClientMem) HGetAll(ctx context.Context, key string) map[string]string

func (*ClientMem) HSet

func (cache *ClientMem) HSet(ctx context.Context, key string, values ...interface{}) error

func (*ClientMem) HSetExp

func (cache *ClientMem) HSetExp(ctx context.Context, key string, expiration time.Duration, values ...interface{}) error

func (*ClientMem) HSetNX

func (cache *ClientMem) HSetNX(ctx context.Context, key string, field string, value interface{}, expiration time.Duration) (set bool, err error)

func (*ClientMem) Set

func (cache *ClientMem) Set(ctx context.Context, key string, values interface{}, expiration time.Duration) error

type Service

type Service interface {
	HSet(ctx context.Context, key string, values ...interface{}) error
	Set(ctx context.Context, key string, values interface{}, expiration time.Duration) error
	HSetExp(ctx context.Context, key string, expiration time.Duration, values ...interface{}) error
	HSetNX(ctx context.Context, key string, field string, value interface{}, expiration time.Duration) (set bool, err error)
	Expire(ctx context.Context, key string, expiration time.Duration) error
	Get(ctx context.Context, key string) (interface{}, error)
	HGet(ctx context.Context, key string, field string) (string, error)
	HGetAll(ctx context.Context, key string) map[string]string
	HDel(ctx context.Context, key string, fields string) error
	Del(ctx context.Context, key string) error
}

func GetCacheClient

func GetCacheClient() Service

func GetCacheMemClient

func GetCacheMemClient() Service

func NewCacheService

func NewCacheService(inMemory bool, host, port, password string) (Service, error)

Jump to

Keyboard shortcuts

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