Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arriqaaq/set
Set is an in-memory Redis like set datastructure
https://github.com/arriqaaq/set
data-structures golang redis
Last synced: 3 months ago
JSON representation
Set is an in-memory Redis like set datastructure
- Host: GitHub
- URL: https://github.com/arriqaaq/set
- Owner: arriqaaq
- License: mit
- Created: 2022-03-01T09:40:45.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-07T08:14:32.000Z (almost 3 years ago)
- Last Synced: 2024-06-20T00:26:03.480Z (7 months ago)
- Topics: data-structures, golang, redis
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# set
Set is an in-memory Redis like [set](https://redis.io/commands#set) datastructureGetting Started
===============## Installing
To start using hash, install Go and run `go get`:
```sh
$ go get -u github.com/arriqaaq/set
```This will retrieve the library.
## Usage
```go
package mainimport "github.com/arriqaaq/set"
type kv struct{k,v string}
func main() {
key:="set1"// SAdd (accepts any value)
s := set.New()
s.SAdd(key, "a")
s.SAdd(key, 1)
s.SAdd(key, &kv{1,2})// SPop
s.SPop("set#2", 1)
isMember := set.SIsMember(key, "a")
assert.Equal(t, true, isMember)// SRem
n := set.SRem(key, "member_1")
assert.Equal(t, true, n)// SUnion
set2 := makeSet(3)set2.SAdd("set2", "a")
set2.SAdd("set2", "b")
set2.SAdd("set2", "c")members := set.SUnion(key, "set2")
assert.Equal(t, 2, len(members))// SDiff
members := set.SDiff(key, "set2")
assert.Equal(t, 0, len(members))}
```## Supported Commands
```go
SADD
SCARD
SDIFF
SDIFFSTORE
SINTER
SINTERSTORE
SISMEMBER
SMEMBERS
SMISMEMBER
SMOVE
SPOP
SRANDMEMBER
SREM
SUNION
SUNIONSTORE
```