ZSet is an in-memory Redis like sorted set datastructure

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 "github.com/arriqaaq/zset"

type kv struct{k,v string}

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(testKey, "ced")
	assert.Equal(t, 1, int(score))

    // ZRank
	rank := n.ZRank(testKey, "ced")
	assert.Equal(t, 0, int(rank))

    // ZRevRank
	rank := n.ZRevRank(testKey, "ced")
	assert.Equal(t, 6, int(rank))

    // ZIncrBy
	n.ZIncrBy(testKey, 300, "ced")
	_, score := n.ZScore(testKey, "ced")
	assert.Equal(t, 301, int(score))

}

Supported Commands

Supported  commands

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

go/golang: fast bit set Bloom filter

package implements a fast bloom filter with real 'bitset' and JSONMarshal/JSONUnmarshal to store/reload the Bloom filter.

Nov 3, 2022

Disjoint Set data structure implementation in Go

dsu Implementation of the Disjoint-Set data structure. The Disjoint-Set, Also called a Union-Find or Merge-Find set, is a data structure that stores a

Dec 9, 2022

A fast (5x) string keyed read-only map for Go - particularly good for keys using a small set of nearby runes.

faststringmap faststringmap is a fast read-only string keyed map for Go (golang). For our use case it is approximately 5 times faster than using Go's

Jan 8, 2023

A close implementation of JavaScript's Set written in Go

Set The Set struct allows unique values storing of any type. Initializing a Set s := set.New() // Empty Set s := set.New("hi", 45, Person{name: "Gophe

Dec 20, 2021

Collections for Golang using generics. Currently containing Hash Set.

Collections for Golang using generics. Currently containing Hash Set.

Implementation of missing colections for Golang using Generics. Free of dependencies. Curently in early development phase. Requirements Go 1.18+ Insta

Dec 30, 2021

A bloom filter is a probabilistic data structure that is used to determine if an element is present in a set

A Go implementation of a bloom filter, with support for boltdb and badgerdb as optional in-memory persistent storage.

Jul 4, 2022

IntSet - Integer based Set based on a bit-vector

IntSet - Integer based Set based on a bit-vector Every integer that is stored will be converted to a bit in a word in which its located. The words are

Feb 2, 2022

Fast in-memory key:value store/cache with TTL

MCache library go-mcache - this is a fast key:value storage. Its major advantage is that, being essentially a thread-safe . map[string]interface{} wit

Nov 11, 2022

An in-memory string-interface{} map with various expiration options for golang

TTLCache - an in-memory cache with expiration TTLCache is a simple key/value cache in golang with the following functions: Expiration of items based o

Jan 8, 2023
Comments
  • Listed sample code won't compile

    Listed sample code won't compile

    Tried to compile the sample code listed in readme file and gives several errors

    # command-line-arguments
    ./a.go:13:28: cannot use 1 (type untyped int) as type string in field value
    ./a.go:13:30: cannot use 2 (type untyped int) as type string in field value
    ./a.go:16:23: undefined: testKey
    ./a.go:17:2: undefined: assert
    ./a.go:17:15: undefined: t
    ./a.go:20:18: undefined: testKey
    ./a.go:21:2: undefined: assert
    ./a.go:21:15: undefined: t
    ./a.go:24:7: no new variables on left side of :=
    ./a.go:29:11: no new variables on left side of :=
    ./a.go:21:15: too many errors
    
    
Generic types that are missing from Go, including sets, trees, sorted lists, etc.

go-typ Generic types that are missing from Go, including sets, trees, sorted lists, etc. All code is implemented with 0 dependencies and in pure Go co

Dec 4, 2022
Package mafsa implements Minimal Acyclic Finite State Automata in Go, essentially a high-speed, memory-efficient, Unicode-friendly set of strings.

MA-FSA for Go Package mafsa implements Minimal Acyclic Finite State Automata (MA-FSA) with Minimal Perfect Hashing (MPH). Basically, it's a set of str

Oct 27, 2022
A tree like tool help you to explore data structures in your redis server
 A tree like tool help you to explore data structures in your redis server

Redis-view is a tree like tool help you explore data structures in your redis server

Mar 17, 2022
Probabilistic set data structure
Probabilistic set data structure

Your basic Bloom filter Golang probabilistic set data structure A Bloom filter is a fast and space-efficient probabilistic data structure used to test

Dec 15, 2022
A simple set type for the Go language. Trusted by Docker, 1Password, Ethereum and Hashicorp.

golang-set The missing set collection for the Go language. Until Go has sets built-in...use this. Coming from Python one of the things I miss is the s

Jan 8, 2023
Set is a useful collection but there is no built-in implementation in Go lang.

goset Set is a useful collection but there is no built-in implementation in Go lang. Why? The only one pkg which provides set operations now is golang

Sep 26, 2022
A simple Set data structure implementation in Go (Golang) using LinkedHashMap.

Set Set is a simple Set data structure implementation in Go (Golang) using LinkedHashMap. This library allow you to get a set of int64 or string witho

Sep 26, 2022
Set data structure for Go

Archived project. No maintenance. This project is not maintained anymore and is archived.. Please create your own map[string]Type or use one of the ot

Nov 21, 2022
Set data structure for Go

Archived project. No maintenance. This project is not maintained anymore and is archived.. Please create your own map[string]Type or use one of the ot

Nov 21, 2022
Package set is a small wrapper around the official reflect package that facilitates loose type conversion and assignment into native Go types.

Package set is a small wrapper around the official reflect package that facilitates loose type conversion and assignment into native Go types. Read th

Dec 27, 2022