你确认删除该任务么?此任务一旦删除不可恢复。
|
|
5 年前 | |
|---|---|---|
| .. | ||
| .drone.yml | 6 年前 | |
| .gitignore | 5 年前 | |
| LICENSE | 6 年前 | |
| README.md | 5 年前 | |
| error.go | 5 年前 | |
| go.mod | 5 年前 | |
| go.sum | 5 年前 | |
| queue.go | 5 年前 | |
| set.go | 5 年前 | |
| uniquequeue.go | 5 年前 | |
Level queue is a simple queue golang library base on go-leveldb.
go get gitea.com/lunny/levelqueue
queue, err := levelqueue.Open("./queue")
err = queue.RPush([]byte("test"))
// pop an element from left of the queue
data, err = queue.LPop()
// if handle success, element will be pop, otherwise it will be keep
queue.LHandle(func(dt []byte) error{
return nil
})
You can now create a Set from a leveldb:
set, err := levelqueue.OpenSet("./set")
added, err:= set.Add([]byte("member1"))
has, err := set.Has([]byte("member1"))
members, err := set.Members()
removed, err := set.Remove([]byte("member1"))
And you can create a UniqueQueue from a leveldb:
queue, err := levelqueue.OpenUnique("./queue")
err := queue.RPush([]byte("member1"))
err = queue.LPush([]byte("member1"))
// Will return ErrAlreadyInQueue
// and so on.
If you have an already open DB you can create these from this using the
NewQueue, NewUniqueQueue and NewSet functions.
暂无描述
Go SVG JavaScript Vue Roff other