Categorygithub.com/kvtools/redis
modulepackage
1.1.0
Repository: https://github.com/kvtools/redis.git
Documentation: pkg.go.dev

# README

Valkeyrie Redis

GoDoc Build Status Go Report Card

valkeyrie provides a Go native library to store metadata using Distributed Key/Value stores (or common databases).

Compatibility

A storage backend in valkeyrie implements (fully or partially) the Store interface.

CallsRedis
Put🟢️
Get🟢️
Delete🟢️
Exists🟢️
Watch🟢️
WatchTree🟢️
NewLock (Lock/Unlock)🟢️
List🟢️
DeleteTree🟢️
AtomicPut🟢️
AtomicDelete🟢️

Supported Versions

Redis versions >= 3.2.6. Key space notification needs to be enabled to have access to Watch and Lock methods.

Examples

package main

import (
	"context"
	"log"

	"github.com/kvtools/redis"
	"github.com/kvtools/valkeyrie"
)

func main() {
	ctx := context.Background()

	config := &redis.Config{
		Bucket: "example",
	}

	kv, err := valkeyrie.NewStore(ctx, redis.StoreName, []string{"localhost:8500"}, config)
	if err != nil {
		log.Fatal("Cannot create store")
	}

	key := "foo"

	err = kv.Put(ctx, key, []byte("bar"), nil)
	if err != nil {
		log.Fatalf("Error trying to put value at key: %v", key)
	}

	pair, err := kv.Get(ctx, key, nil)
	if err != nil {
		log.Fatalf("Error trying accessing value at key: %v", key)
	}

	log.Printf("value: %s", string(pair.Value))

	err = kv.Delete(ctx, key)
	if err != nil {
		log.Fatalf("Error trying to delete key %v", key)
	}
}

# Functions

New creates a new Redis client.
NewWithCodec creates a new Redis client with codec config.

# Constants

StoreName the name of the store.

# Variables

ErrAbortTryLock is thrown when a user stops trying to seek the lock by sending a signal to the stop chan, this is used to verify if the operation succeeded.
ErrInvalidRoutesOptions is thrown when Redis Sentinel is enabled with RouteByLatency & RouteRandomly options without the ClusterClient.
ErrMasterSetMustBeProvided is thrown when Redis Sentinel is enabled and the MasterName option is undefined.
ErrMultipleEndpointsUnsupported is thrown when there are multiple endpoints specified for Redis.

# Structs

Config the Redis configuration.
JSONCodec is a simple codec to read and write valkeyrie JSON object.
RawCodec is a simple codec to read and write string.
Sentinel holds the Redis Sentinel configuration.
Store implements the store.Store interface.

# Interfaces

Codec KVPair persistence interface.