Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wredis Build Status Go Report Card Coverage Status GoDoc

Wredis is a wrapper around the redigo redis.Pool and provides an easy-to-use API for Redis commands

Getting Started

Go Get

go get github.com/crowdriff/wredis

Usage

API Reference

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)
}

Implemented Commands

  • 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

Convenience methods

  • 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

Contributing

Install Tools and Dependencies

make tools
make deps

Contribute

  1. Fork
  2. Make changes
  3. Add tests
  4. Run make test
  5. Send a PR

About

Wrapped Redis for Golang

Resources

Stars

7 stars

Watchers

8 watching

Forks

Releases

Packages

Contributors

Languages