Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redis-async-gen

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis-async-gen

A little library to make scanning for a set of keys in a Redis database a little bit more tolerable.

  • 0.1.3
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Build status

README

A little library to make scanning for a set of keys in a Redis database a little bit more tolerable.

Scanning a Redis database for a key matching a pattern is not necessarily hard, but if you use the standard Redis NPM library, then there's still quite some stuff that you need to carefully handle yourself.

This project figures all of that can be simplified by introducing a generator for scanning keys, allowing the blissfully ignorant JavaScript programmer to simply use a for comprehension:

const redis = require('redis')
const client = redis.createClient(…)
const generators = require('redis-async-gen')
const { keysMatching } = generators.using(client)

…

for await (const key of keysMatching('test*')) {
  console.info(key)
}

Under the hoods, this library will execute the scan command repeatedly, fetching new sets of keys whenever it needs. The underlying cursor logic is completely hidden.

If you are using the for comprehension to loop over keys matching a certain pattern, then be advised that you can break out of the loop at any time using the break operation.

The library also has support for scanning values from a Set. The following will retrieve all values from a Set defined at key aaa, starting with the prefix test.

const redis = require('redis')
const client = redis.createClient(…)
const generators = require('redis-async-gen')
const { keysMatching } = generators.using(client)

…

for await (const key of valuesMatching('aaa', 'test*')) {
  console.info(key)
}

FAQs

Package last updated on 02 Jul 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc