cache

package
v0.0.0-...-aad8beb Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cacher

type Cacher interface {
	Get(key string) (string, error)
	Set(key, value string, expireInSec int) error
}

Cacher is an interface that represents an object that caches objects.

type Config

type Config struct {
	Name                  string
	Topology              string
	Host                  string
	Port                  int
	Password              string
	SentinelMasterName    string
	PoolSize              int
	MinIdleConnections    int
	PoolTimeout           time.Duration
	ConnectionIdleTimeout time.Duration
	DialTimeout           time.Duration
	ReadTimeout           time.Duration
	WriteTimeout          time.Duration
	MaxRetries            int
	MaxRetryBackoff       time.Duration
}

Config has the redis configs

type RedisCache

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

RedisCache is a redis cache object.

func NewRedis

func NewRedis(config Config) *RedisCache

NewRedis instantiate a new redis cluster client

func (RedisCache) Get

func (r RedisCache) Get(ctx context.Context, key string) (string, error)

Get is a method that gets a value from cache.

func (RedisCache) Set

func (r RedisCache) Set(ctx context.Context, key, value string, expireInSec int) error

Set is a method that sets a value to cache.

Jump to

Keyboard shortcuts

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