v2.0.0 Latest Latest

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

Go to latest
Published: Nov 3, 2023 License: Apache-2.0 Imports: 5 Imported by: 1



Package redis provides the handler function for the Redis trigger, as well as access to Redis within Spin components.



This section is empty.


This section is empty.


func Handle

func Handle(fn func(payload []byte) error)

Handle sets the handler function for redis. It must be set in an init() function.


type Client

type Client struct {
	// contains filtered or unexported fields

Client is a Redis client.

func NewClient

func NewClient(address string) *Client

NewClient returns a Redis client.

func (*Client) Del

func (c *Client) Del(keys ...string) (int64, error)

Del removes the specified keys. A key is ignored if it does not exist.

func (*Client) Execute

func (c *Client) Execute(command string, arguments ...any) ([]*Result, error)

Execute runs the specified Redis command with the specified arguments, returning zero or more results. This is a general-purpose function which should work with any Redis command.

Arguments must be string, []byte, int, int64, or int32.

func (*Client) Get

func (c *Client) Get(key string) ([]byte, error)

Get the value of a key. An error is returned if the value stored at key is not a string.

func (*Client) Incr

func (c *Client) Incr(key string) (int64, error)

Incr increments the number stored at key by one. If the key does not exist, it is set to 0 before performing the operation. An error is returned if the key contains a value of the wrong type or contains a string that can not be represented as integer.

func (*Client) Publish

func (c *Client) Publish(channel string, payload []byte) error

Publish a Redis message to the specified channel.

func (*Client) Sadd

func (c *Client) Sadd(key string, values ...string) (int64, error)

Sadd adds the specified values to the set for the specified key, creating it if it does not already exist.

func (*Client) Set

func (c *Client) Set(key string, payload []byte) error

Set key to value. If key alreads holds a value, it is overwritten.

func (*Client) Smembers

func (c *Client) Smembers(key string) ([]string, error)

Smembers gets the elements of the set for the specified key.

func (*Client) Srem

func (c *Client) Srem(key string, values ...string) (int64, error)

Srem removes the specified elements from the set for the specified key. This has no effect if the key does not exist.

type Result

type Result struct {
	Kind ResultKind
	Val  any

Result represents a value returned from a Redis command.

type ResultKind

type ResultKind uint8

ResultKind represents a result type returned from executing a Redis command.

const (
	ResultKindNil ResultKind = iota

func (ResultKind) GoString

func (r ResultKind) GoString() string

GoString implements fmt.GoStringer.

func (ResultKind) String

func (r ResultKind) String() string

String implements fmt.Stringer.

Jump to

Keyboard shortcuts

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