redis

package
v0.0.0-...-c1868ec Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToStringValues

func ConvertToStringValues(value interface{}) string

Types

type RedisCacheClient

type RedisCacheClient interface {
	Ping() error

	//Get
	Get(ctx context.Context, key string) ([]byte, error)
	GetMatchingKeys(ctx context.Context, pattern string) ([]string, error)
	GetListValues(ctx context.Context, listKey string, values int) ([]interface{}, error)

	//Set
	Set(ctx context.Context, key string, value []byte, timeout int) error
	PushToList(ctx context.Context, listKey string, value []byte) error

	//Remove
	RemoveFromList(ctx context.Context, listKey string, value []byte) (int64, error)

	//PubSub
	PublishMessageToChannel(ctx context.Context, channel string, message []byte) error
	Subscribe(ctx context.Context, channels []string) (*redis.PubSubConn, error)
}

func ReturnRedisClient

func ReturnRedisClient() (RedisCacheClient, error)

type RedisClient

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

func (*RedisClient) Get

func (r *RedisClient) Get(ctx context.Context, key string) ([]byte, error)

Get will search for a key and return the data found If no data is found, will return nil

func (*RedisClient) GetListValues

func (r *RedisClient) GetListValues(ctx context.Context, listKey string, values int) ([]interface{}, error)

func (*RedisClient) GetMatchingKeys

func (r *RedisClient) GetMatchingKeys(ctx context.Context, pattern string) ([]string, error)

GetKeys will check for a pattern and retrieve keys matching the pattern

func (*RedisClient) Ping

func (r *RedisClient) Ping() error

Ping the Redis client

func (*RedisClient) PublishMessageToChannel

func (r *RedisClient) PublishMessageToChannel(ctx context.Context, channel string, message []byte) error

func (*RedisClient) PushToList

func (r *RedisClient) PushToList(ctx context.Context, listKey string, value []byte) error

func (*RedisClient) RemoveFromList

func (r *RedisClient) RemoveFromList(ctx context.Context, listKey string, value []byte) (int64, error)

func (*RedisClient) Set

func (r *RedisClient) Set(ctx context.Context, key string, value []byte, timeout int) error

Set sets the given key and value with expiry time in seconds, if any

func (*RedisClient) Subscribe

func (r *RedisClient) Subscribe(ctx context.Context, channels []string) (*redis.PubSubConn, error)

Jump to

Keyboard shortcuts

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