Socket
Socket
Sign inDemoInstall

block-sequence-redis

Package Overview
Dependencies
12
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    block-sequence-redis

A redis implementation of block-sequence


Version published
Weekly downloads
4
Maintainers
1
Install size
2.37 MB
Created
Weekly downloads
 

Changelog

Source

[1.1.0]

Changed

  • Erroring when sequence exceeds Number.MAX_SAFE_INT

Readme

Source

block-sequence-redis

A redis implementation of block-sequence.

NPM version NPM downloads Build Status Code Climate Test Coverage Code Style Dependency Status devDependencies Status

Usage

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

Keywords

FAQs

Last updated on 26 Jan 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc