redis

package
v0.0.0-...-1f5ab75 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PubKeyEventSub Key = "EventSub"

	Prefix = "Melonbot:"

	Nil = redis.Nil
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Instance

type Instance interface {
	// Ping checks if the redis instance is alive
	Ping(context.Context) error

	// Get returns the value of the key
	Get(context.Context, Key) (string, error)
	// Set sets the value of the key
	//
	// No expiration is set
	Set(context.Context, Key, string) error
	// Del deletes the key
	Del(context.Context, Key) error
	// Expire sets the expiration of the key
	Expire(context.Context, Key, time.Duration) error

	// Subscribe subscribes to a channel and returns a channel
	Subscribe(context.Context, Key) chan PubMessage
	// Publish publish a struct to a channel
	//
	// Data is sent as {
	// 	"Type": Key
	// 	"Data": interface{}
	// }
	//
	// This allows the receiver to know what type of data it is receiving
	//
	// Such as Eventsub, where the type could be "foo" or "bar"
	//
	// And the data would could be different for each type
	Publish(context.Context, Key, PubJSON) error

	// Prefix returns the prefix used for all keys
	Prefix() string
}

func Create

func Create(ctx context.Context, address string) (Instance, error)

type Key

type Key string

func (Key) String

func (k Key) String() string

type PubJSON

type PubJSON interface {
	Type() string
}

type PubMessage

type PubMessage struct {
	Channel string
	Payload string
}

type SendEvent

type SendEvent struct {
	Type Key
	Data interface{}
}

Jump to

Keyboard shortcuts

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