v1.5.1 Latest Latest

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

Go to latest
Published: Sep 26, 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.



View Source
const (
	RedisParameterKindInt64 = iota
View Source
const (
	RedisResultKindNil = iota


This section is empty.


func Del added in v0.7.0

func Del(addr string, keys []string) (int64, error)

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

func Get

func Get(addr, 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 Handle

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

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

func Incr added in v0.7.0

func Incr(addr, key string) (int64, error)

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 Publish

func Publish(addr, channel string, payload []byte) error

Publish a Redis message to the specificed channel and return an error, if any.

func Sadd added in v0.9.0

func Sadd(addr string, key string, values []string) (int64, error)

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

func Set

func Set(addr, key string, payload []byte) error

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

func Smembers added in v0.9.0

func Smembers(addr string, key string) ([]string, error)

Get the elements of the set for the specified key.

func Srem added in v0.9.0

func Srem(addr string, key string, values []string) (int64, error)

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


type RedisParameter added in v0.9.0

type RedisParameter struct {
	Kind RedisParameterKind
	Val  interface{}

type RedisParameterKind added in v0.9.0

type RedisParameterKind uint8

type RedisResult added in v0.9.0

type RedisResult struct {
	Kind RedisResultKind
	Val  interface{}

func Execute added in v0.9.0

func Execute(addr string, command string, arguments []RedisParameter) ([]RedisResult, error)

Run 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.

type RedisResultKind added in v0.9.0

type RedisResultKind uint8

Jump to

Keyboard shortcuts

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