Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arriqaaq/zset
ZSet is an in-memory Redis like sorted set datastructure
https://github.com/arriqaaq/zset
data-structure data-structures golang redis skiplist
Last synced: 2 months ago
JSON representation
ZSet is an in-memory Redis like sorted set datastructure
- Host: GitHub
- URL: https://github.com/arriqaaq/zset
- Owner: arriqaaq
- License: mit
- Created: 2022-03-02T10:15:31.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-20T17:27:03.000Z (almost 3 years ago)
- Last Synced: 2024-06-21T05:02:11.692Z (6 months ago)
- Topics: data-structure, data-structures, golang, redis, skiplist
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zset
Getting Started
===============## Installing
To start using hash, install Go and run `go get`:
```sh
$ go get -u github.com/arriqaaq/zset
```This will retrieve the library.
## Usage
```go
package mainimport (
"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
```go
Supported commandsZADD
ZCARD
ZINCRBY
ZPOPMAX
ZPOPMIN
ZRANGE
ZRANGEBYSCORE
ZRANGEWITHSSCORES
ZRANK
ZREM
ZREVRANGE
ZREVRANGEWITHSSCORES
ZREVRANK
ZSCORE
```