https://github.com/guidesmiths/block-sequence-redis
A redis implementation of block-sequence
https://github.com/guidesmiths/block-sequence-redis
Last synced: 2 months ago
JSON representation
A redis implementation of block-sequence
- Host: GitHub
- URL: https://github.com/guidesmiths/block-sequence-redis
- Owner: guidesmiths
- Created: 2016-05-02T00:46:40.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-10T06:07:21.000Z (over 2 years ago)
- Last Synced: 2025-05-13T20:26:53.496Z (2 months ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 0
- Watchers: 14
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# block-sequence-redis
A redis implementation of [block-sequence](https://www.npmjs.com/package/block-sequence).[](https://www.npmjs.com/package/block-sequence-redis)
[](https://www.npmjs.com/package/block-sequence-redis)
[](https://travis-ci.org/guidesmiths/block-sequence-redis)
[](https://codeclimate.com/github/guidesmiths/block-sequence-redis)
[](https://codeclimate.com/github/guidesmiths/block-sequence-redis/coverage)
[](https://github.com/guidesmiths/eslint-config-imperative)
[](https://david-dm.org/guidesmiths/block-sequence-redis)
[](https://david-dm.org/guidesmiths/block-sequence-redis?type=dev)## Usage
```js
const BlockArray = require('block-sequence').BlockArray
const init = require('block-sequence-redis')// Initialise the redis Block Sequence Driver
init({ host: '127.0.0.1' }, (err, driver) => {
if (err) throw err// Ensure the sequence exists
driver.ensure({ name: 'my-sequence' }, (err, sequence) => {
if (err) throw err// Create a block array containing 1000 ids per block (defaults to 2 blocks)
const idGenerator = new BlockArray({ block: { sequence: sequence, driver: driver, size: 1000 } })// Grab the next id
idGenerator.next((err, id) => {
if (err) throw err
console.log(id)
})
})
})
```
See https://github.com/NodeRedis/node_redis for all connection parameters