redis

package
v0.1.1-0...-4a89cbd Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConnection

func NewConnection(host, port, password string, db int) *redis.Client

Types

type RedisCache

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

func NewRedisCache

func NewRedisCache(client *redis.Client) *RedisCache

func (*RedisCache) Del

func (rs *RedisCache) Del(key string) error

func (*RedisCache) Get

func (rs *RedisCache) Get(key string) ([]byte, error)

func (*RedisCache) Set

func (rs *RedisCache) Set(key string, value []byte, expiration time.Duration) error

type RedisPubSub

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

RedisPubSub implements the PublishSubscribe interface, but publishes to all subscribers. All subscribers will receive the message.

func NewRedisPubSub

func NewRedisPubSub(client *redis.Client) *RedisPubSub

func (*RedisPubSub) Publish

func (rpb *RedisPubSub) Publish(queue string, value string) error

func (*RedisPubSub) Subscribe

func (rpb *RedisPubSub) Subscribe(queueid string, msg chan string) error

Subscribe subcribes the client to a certain queue, and uses a channel to indicate something on that subscription channel has sent a message

type RedisQueue

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

RedisQueue implements the PublishSubscribe interface, but only publishes to one subscriber. Implemented by having Publishers push into a queue, and Subscribers read from the queue and pop off from the top.

func NewRedisQueue

func NewRedisQueue(client *redis.Client, queueID, groupID string) *RedisQueue

NewRedisQueue creates a new queue and a group associated with that queue. Underlying mecahnism uses Redis Streams.

func (*RedisQueue) Publish

func (rq *RedisQueue) Publish(queueID string, value []byte) error

Publish value to a queue, based on queueID.

func (*RedisQueue) Subscribe

func (rq *RedisQueue) Subscribe(queueID, groupID, consumerID string, msg chan []byte) error

Subscribe creates a goroutine that subscribes to a RedisStream, based on queueID, groupID, consumerID. Sends data values to a msg []byte channel.

Jump to

Keyboard shortcuts

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