redislib

package
v0.0.0-...-a99fd5a Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 4 Imported by: 0

README

golang-modules/redislib

Golang Redis Module

Redis Server

Redis server start

$ cd docker
$ docker-compose up -d
func New

Make redis session

func New(addr string, passwd string, db int) *redis.Client
func Pub

Send Publish message

func Pub(rdb *redis.Client, title string, data string) error

(example)
rdb := New("localhost:6379", "changeme", 0)
Pub(rdb, "Project", `{"name":"iskraman", "age":12}`)
func Sub

Make subscriber session

func Sub(rdb *redis.Client, title string) *redis.PubSub
func SubRecvMsg

Receive Subscribe message

func SubRecvMsg(subscriber *redis.PubSub) (string, error)

(example)
rdb := New("localhost:6379", "changeme", 0)
subs := Sub(rdb, "Project")
for {
	msg, _ := SubRecvMsg(subs)
	syslog.STD(msg)
}
func Set

Redis set key, value

func Set(rdb *redis.Client, key string, val string) error

(example)
err := Set(rdb, "key", "value")
func Get

Redis get key

func Get(rdb *redis.Client, key string) (string, error)

(example)
val, err := Get(rdb, "key")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Del

func Del(rdb interface{}, key string) bool

func Get

func Get(rdb interface{}, key string) (string, error)

func GetJson

func GetJson(rdb interface{}, key string, data interface{}) error

func HDel

func HDel(rdb interface{}, key string, field string) bool

func HGet

func HGet(rdb interface{}, key string, field string) (string, error)

func HGetAll

func HGetAll(rdb interface{}, key string) (map[string]string, error)

func HSet

func HSet(rdb interface{}, key string, field map[string]interface{}) error

func Keys

func Keys(rdb interface{}, key string) []string

func New

func New(addr string, passwd string, db int) *redis.Client

func NewAWS

func NewAWS(addr string, passwd string, username string) *redis.ClusterClient

func Pub

func Pub(rdb interface{}, title string, data string) error

func Set

func Set(rdb interface{}, key string, val string) error

func SetJson

func SetJson(rdb interface{}, key string, val interface{}) error

func Sub

func Sub(rdb interface{}, title string) *redis.PubSub

func SubRecvMsg

func SubRecvMsg(subscriber *redis.PubSub) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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