Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kessler/qool
Qool, a leveldb backed Queue
https://github.com/kessler/qool
database javascript leveldb node-js nodejs queue
Last synced: about 1 month ago
JSON representation
Qool, a leveldb backed Queue
- Host: GitHub
- URL: https://github.com/kessler/qool
- Owner: kessler
- License: mit
- Archived: true
- Created: 2016-07-10T03:41:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-09T19:29:44.000Z (over 8 years ago)
- Last Synced: 2024-12-01T00:31:58.535Z (about 1 month ago)
- Topics: database, javascript, leveldb, node-js, nodejs, queue
- Language: JavaScript
- Homepage:
- Size: 50.8 KB
- Stars: 42
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# qool
**a leveldb backed [Queue](https://en.wikipedia.org/wiki/Queue_(abstract_data_type))**
[![npm status](http://img.shields.io/npm/v/qool.svg?style=flat-square)](https://www.npmjs.org/package/qool)
- durable
- strict FIFO ordering
- dequeus with timeouts (called lease())
- embeddable## Example
### Simple
```javascript
const Qool = require('qool')
const level = require('level-bytewise')const db = level('db')
const queue = Qool.create(db)queue.enqueue('a')
queue.enqueue('b', (err) => {})queue.dequeue()
queue.dequeue((err, value) => {})
```
##### notes
Enqueue and Dequeue are batched under the hood, so callbacks are invoked synchronously. This means that you can only include a last callback and forgo all the others for Enqueues and Dequeues that happen in the same tick### Lease
```javascript
const Qool = require('qool')
const level = require('level-bytewise')const db = level('db')
const queue = Qool.create(db, 1000 * 10)queue.enqueue('a')
queue.enqueue('b', (err) => {})queue.lease((err, leaseKey, value) => {
// do something with the data// delete the item permanently from the queue
queue.delete(leaseKey, (err) => {})
})// TBD
// lease with a non default timeout
//queue.leaseWithTimeout(1000 * 2, (err, leaseKey, value) => {})
```### Peek
```javascript
const Qool = require('qool')
const level = require('level-bytewise')const db = level('db')
const queue = Qool.create(db)queue.enqueue('a')
queue.enqueue('b', (err) => {})queue.peek((err, value) => {
// value === 'a'
})queue.peekMany((err, results) => {
// results === [{ key: ..., value: 'a' }, { key: ..., value: 'b' }]
})
```Some ramblings on internal design are [here](./notes.md)
## license
### TODO
- enhance tests
- implement length property
- should we have a version of dequeue that "waits" if the queue is empty
- expiry for enqueued items[MIT](http://opensource.org/licenses/MIT) © yaniv kessler