datastore

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisStore

type RedisStore struct {
	Client *redis.Client
}

func NewRedisStore

func NewRedisStore(addr string, password string, db int) (*RedisStore, error)

func (*RedisStore) BLMOVE

func (s *RedisStore) BLMOVE(ctx context.Context, source string, destination string) (string, error)

Create a BLMOVE method that will move an element from a list to another list atomically

func (*RedisStore) BRPop

func (s *RedisStore) BRPop(ctx context.Context, key string) (string, error)

Create a BRPOP/BLPOP method that will remove and return the first element of a list

func (*RedisStore) Delete

func (s *RedisStore) Delete(ctx context.Context, key string) error

Delete removes a key-value pair from the store

func (*RedisStore) Exists

func (s *RedisStore) Exists(ctx context.Context, key string) (bool, error)

Exists checks if a key exists in the store

func (*RedisStore) Get

func (s *RedisStore) Get(ctx context.Context, key string) (string, error)

Get retrieves a value from the store by its key

func (*RedisStore) LPush

func (s *RedisStore) LPush(ctx context.Context, key string, value interface{}) error

Create a LPUSH method that will add a message to a list

func (*RedisStore) LREM

func (s *RedisStore) LREM(ctx context.Context, key string, count int64, value interface{}) error

Create a LREM method that will remove the first count occurrences of elements equal to value from the list stored at key

func (*RedisStore) Publish

func (s *RedisStore) Publish(ctx context.Context, channel string, message interface{}) error

Implement your pub/sub methods here Publish sends a message to a channel

func (*RedisStore) Set

func (s *RedisStore) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error

Set adds a key-value pair to the store

func (*RedisStore) Subscribe

func (s *RedisStore) Subscribe(ctx context.Context, channel string) (<-chan *redis.Message, error)

Subscribe subscribes to a channel and returns a channel that receives messages

func (*RedisStore) SubscribeLog

func (s *RedisStore) SubscribeLog(ctx context.Context) (<-chan *redis.Message, error)

Create a Subscribe method that log all messages received from the channel

Jump to

Keyboard shortcuts

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