redis

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheService

type CacheService interface {
	Set(ctx context.Context, key string, value any, expiration time.Duration) *redis.StatusCmd
	Get(ctx context.Context, key string) *redis.StringCmd
	FlushAll(ctx context.Context) *redis.StatusCmd
	Del(ctx context.Context, keys ...string) *redis.IntCmd
	Close() error
}

CacheService combines methods of redis client and redis clustered client to have one impl that works for both, reduced to only what we use

func NewRedisCacheService

func NewRedisCacheService(clustered bool, redisSettings Settings) CacheService

NewRedisCacheService establishes connection to Redis and creates client. db is the 0-16 db instance to use from redis. tls is whether redis server uses tls - false if eg. running in docker but may be true if in production. url is the redis server url.

type Settings

type Settings struct {
	// URL eg. localhost:6379
	URL      string `yaml:"URL"`
	Password string `yaml:"PASSWORD"`
	// TLS enable tls
	TLS bool `yaml:"TLS"`
	// KeyPrefix prepends this string to all keys. Makes it easier with many services sharing redis cluster. If empty no prefix.
	KeyPrefix string `yaml:"KEY_PREFIX"`
}

Settings add these redis settings to your settings struct

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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