Skip to content

Sovietaced/go-redisson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 := mapp.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 := mapp.NewMap(client, mapp.WithKeyMarshaler(...), mapp.WithValueMarshaller(...))

About

Distributed data structures backed by Redis

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages