go-redisson

module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: MIT

README

go-redisson

Test GoDoc Go Report

Distributed data structures backed by Redis. Heavily inspired by Redisson.

Examples

Distributed Lock

The Mutex struct aims to provide identical semantics to the sync.Mutex package.

ctx := context.Background()
client := redis.NewClient(&redis.Options{Addr: endpoint})
mutex := mutex.NewMutex(client, "test")
err := mutex.Lock(ctx)
err = mutex.Unlock(ctx)
Distributed Map

The Map struct aims to provide similar semantics to a native Go map.

ctx := context.Background()
client := redis.NewClient(&redis.Options{Addr: endpoint})
m := rmap.NewMap(client, "my-namespace")
err = m.Set(ctx, "key", "value")
value, exists, err := m.Get(ctx, "key")

The Map struct supports generics so you can use any struct you'd like for the key/value. By default, structs will be marshalled using json but can be configured with key/value marshalers.


m := rmap.NewMap(client, rmap.WithKeyMarshaler(...), rmap.WithValueMarshaller(...))

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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