Wredis is a wrapper around the redigo redis.Pool
and provides an easy-to-use API for Redis commands
go get github.com/crowdriff/wredis
import (
"log"
"github.com/crowdriff/wredis"
)
var w *wredis.Wredis
func main() {
var err error
if w, err = wredis.NewDefaultPool(); err != nil {
log.Fatal(err.Error())
}
defer w.Close()
if err = w.Set("mykey", "myval"); err != nil {
log.Fatal(err.Error())
}
val, err := w.Get("mykey")
if err != nil {
log.Fatal(err.Error())
}
log.Println(val)
}
- Connection
- Select: switch the redis database
- Keys
- Del: delete a key
- Exists: does a key exist
- Expire: set an expiry time for a key
- Keys: fetch a list of keys that match the given pattern
- Rename: rename a key
- Server
- FlushAll: Flush the contents of the redis server (requires unsafe Wredis)
- FlushDb: Flush the contents of a specific redis db (requires unsafe Wredis)
- Sets
- SAdd: add members to a set
- SCard: count of a set
- SDiffStore: perform a diff and store the results in redis
- SMembers: return the members of a set
- SUnionStore: perform a union and store the results in redis
- Strings
- Get: get a key's value
- Incr: increment a key's value by 1
- Set: set a key's value
- SetEx: set a key's value with an expiry in seconds
- Keys
- DelWithPattern: delete all keys matching a pattern
- Server
- SelectAndFlushDb: selects a db before flushing it
- Strings
- SetExDuration: set a string with an expiry using a
time.Duration
- SetExDuration: set a string with an expiry using a
make tools
make deps
- Fork
- Make changes
- Add tests
- Run
make test
- Send a PR