npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@eturino/ioredis-del-by-pattern

v2.0.1

Published

ioredis util to delete keys by pattern on redis. Supports batches (pipeline) and lets the user decide to use `del` or `unlink` methods.

Downloads

3,150

Readme

@eturino/ioredis-del-by-pattern

npm version Build Status Maintainability Test Coverage

TypeDoc generated docs in here

Github repo here

ioredis util to delete keys by pattern on redis. Supports batches (pipeline) and lets the user decide to use del or unlink methods.

It uses a scanStream in ioredis to gather the matched keys to remove.

Installation

yarn add @eturino/ioredis-del-by-pattern or npm install @eturino/ioredis-del-by-pattern.

Usage

The exported function redisDelByPattern() returns a promise with the number of keys deleted in total, using the given pattern and redis client.

import { redisDelByPattern } from "@eturino/ioredis-del-by-pattern";

const deletedKeysCount: number = await redisDelByPattern({
  pattern: "delete-with-this-prefix-*",
  redis // ioredis client
});

It supports the following params:

  • redis: redis client. (REQUIRED)
  • pattern: match in the redis scan stream. (REQUIRED)
  • deletionMethod: determines the usage of DEL or UNLINK commands (Unlink by default).
  • withPipeline: decide to use a pipeline to execute the commands or on each stream event (no pipeline by default).
  • pipelineBatchLimit: 100 by default, in effect if withPipeline is true.
  • enableLog: if true, actions will be logged using the given logFn.
  • logFn: function to execute to log events. Defaults to (console.log).
  • logWarnFn: function to execute to log events for warn. Defaults to (console.warn).
  • logPrefix: prefix to the logFn (defaults to "[REDIS-DEL-BY-PATTERN] ").
import { redisDelByPattern } from "@eturino/ioredis-del-by-pattern";

const deletedKeysCount: number = await redisDelByPattern({
  pattern: `${prefix}-delete-me*`,
  redis, // ioredis client
  withPipeline: true,
  deletionMethod: RedisDeletionMethod.unlink
});

Acknowledgements

The batched function implementation is heavily based on the article "Find and Delete multiple keys matching by a pattern in Redis: The right way " by Ankit Jain

Development, Commits, versioning and publishing

See The Typescript-Starter docs.

Commits and CHANGELOG

For commits, you should use commitizen

yarn global add commitizen

#commit your changes:
git cz

As typescript-starter docs state:

This project is tooled for conventional changelog to make managing releases easier. See the standard-version documentation for more information on the workflow, or CHANGELOG.md for an example.

# bump package.json version, update CHANGELOG.md, git tag the release
yarn run version

You may find a tool like wip helpful for managing work in progress before you're ready to create a meaningful commit.

Creating the first version

Once you are ready to create the first version, run the following (note that reset is destructive and will remove all files not in the git repo from the directory).

# Reset the repo to the latest commit and build everything
yarn run reset && yarn run test && yarn run doc:html

# Then version it with standard-version options. e.g.:
# don't bump package.json version
yarn run version -- --first-release

# Other popular options include:

# PGP sign it:
# $ yarn run version -- --sign

# alpha release:
# $ yarn run version -- --prerelease alpha

And after that, remember to publish the docs.

And finally push the new tags to github and publish the package to npm.

# Push to git
git push --follow-tags origin master

# Publish to NPM (allowing public access, required if the package name is namespaced like `@somewhere/some-lib`)
yarn publish --access public

Publish the Docs

yarn run doc:html && yarn run doc:publish

This will generate the docs and publish them in github pages.

Generate a version

There is a single yarn command for preparing a new release. See One-step publish preparation script in TypeScript-Starter

# Prepare a standard release
yarn prepare-release

# Push to git
git push --follow-tags origin master

# Publish to NPM (allowing public access, required if the package name is namespaced like `@somewhere/some-lib`)
yarn publish --access public