Skip to content

crowdriff/wredis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

880f5e4 · Apr 8, 2016

History

45 Commits
Oct 15, 2015
Mar 21, 2016
Jan 15, 2016
Feb 13, 2016
Mar 21, 2016
Mar 21, 2016
Nov 19, 2015
Nov 19, 2015
Nov 19, 2015
Nov 19, 2015
Feb 13, 2016
Nov 19, 2015
Jan 15, 2016
Apr 7, 2016
Apr 7, 2016
Nov 19, 2015
Nov 19, 2015
Nov 19, 2015
Nov 15, 2015
Nov 15, 2015
Apr 7, 2016
Nov 19, 2015
Apr 7, 2016
Oct 26, 2015
Nov 15, 2015

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