Skip to content
/ zset Public

ZSet is an in-memory Redis like sorted set datastructure

License

Notifications You must be signed in to change notification settings

arriqaaq/zset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zset

Getting Started

Installing

To start using hash, install Go and run go get:

$ go get -u github.com/arriqaaq/zset

This will retrieve the library.

Usage

package main

import (
	"fmt"

	"github.com/arriqaaq/zset"
)

type kv struct{ k, v int }

func main() {
	key := "zset1"

	// ZAdd (accepts any value)
	n := zset.New()
	n.ZAdd(key, 1, "ced", nil)
	n.ZAdd(key, 1, "efg", &kv{1, 2})

	// ZScore
	_, score := n.ZScore(key, "ced")
	fmt.Println("score: ", int(score))
	// score: 1

	// ZRank
	rank := n.ZRank(key, "ced")
	fmt.Println("zrank: ", int(rank))
	// zrank: 0

	// ZRevRank
	rank = n.ZRevRank(key, "ced")
	fmt.Println("zrevrank: ", int(rank))
	// zrevrank: 1

	// ZIncrBy
	n.ZIncrBy(key, 300, "ced")
	_, score = n.ZScore(key, "ced")
	fmt.Println("score: ", int(score))
	// score: 301
}

Supported Commands

Supported  commands

ZADD
ZCARD
ZINCRBY
ZPOPMAX
ZPOPMIN
ZRANGE
ZRANGEBYSCORE
ZRANGEWITHSSCORES
ZRANK
ZREM
ZREVRANGE
ZREVRANGEWITHSSCORES
ZREVRANK
ZSCORE

About

ZSet is an in-memory Redis like sorted set datastructure

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages