You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lunny Xiao bd3bf6d3bf
continuous-integration/drone/push Build is failing Details
update
7 months ago
.drone.yml update 7 months ago
.gitignore Add Set and UniqueQueue implementations (#1) 3 years ago
LICENSE init project 4 years ago
README.md Use pebble instead of leveldb 7 months ago
error.go Add Set and UniqueQueue implementations (#1) 3 years ago
go.mod Use pebble instead of leveldb 7 months ago
go.sum Use pebble instead of leveldb 7 months ago
queue.go Use pebble instead of leveldb 7 months ago
queue_test.go fix bug 3 years ago
set.go Use pebble instead of leveldb 7 months ago
set_test.go Add Set and UniqueQueue implementations (#1) 3 years ago
uniquequeue.go Use pebble instead of leveldb 7 months ago
uniquequeue_test.go Add Set and UniqueQueue implementations (#1) 3 years ago

README.md

pebblequeue

Pebble queue is a simple queue golang library base on pebbledb.

Build Status

Installation

go get gitea.com/lunny/pebblequeue

Usage

queue, err := pebblequeue.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 pebbledb:

set, err := pebblequeue.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 pebbledb:

queue, err := pebblequeue.OpenUnique("./queue")

err := queue.RPush([]byte("member1"))

err = queue.LPush([]byte("member1"))
// Will return ErrAlreadyInQueue

// and so on.

Creating Queues, UniqueQueues and Sets from already open DB

If you have an already open DB you can create these from this using the NewQueue, NewUniqueQueue and NewSet functions.