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

redis-config-manager

v1.3.1

Published

thin wrapper around redis hashes for storing json serialized data

Downloads

15

Readme

redis-config-manager Build Status

A thin nodejs API wrapper for redis used to store JSON serialized strings under hash subkeys.

Features:

  • Keeps your redis instance root namespace clean by storing everything under one hash key, with subkeys as your main identifier
  • Handles the JSON encode/decode cycle internally
  • Event emitters let you set listeners as needed for handling errors the way you want
  • Uses node-redis module under the hood for its redis client
  • Uses redis-mock for local testing without a redis instance

Requirements:

Tested on NodeJS 12.x and higher

Installation:

Go into your yarn add redis-config-manager or npm install redis-config-manager

Example

See test/unit/rcm.spec.js for more examples.

const RedisConfigManager = require('redis-config-manager');
const source = {
    label: 'rando-name',            // generic name for this instance used in testing
    hashKey: 'rando-key-suffix',   // Suffix used in the hash key storing the data
    client: {
        host: '127.0.0.1',
        port: 6379
        // any other redis client-specific parameters
    },
};
const RCM = new RedisConfigManager(source);
await RCM.init();
await RCM.setConfig('foo',{bar:'quux'});

Methods & Properties:

|Signature| Description | Returns | async/Promise | Deprecated | |---------|-------------|---------|---------------|------------| |.init()| Initialize the manager, redis connection, active keys, etc | Yes | |.setConfig(key,value) | JSON serializes js object of value and writes/overwrites the string hash subkey of key| Boolean true | Yes | |.getConfig(key) | If the string of key is a valid subkey to the hash, will return the JSON.parse value of the string value stored | Object | Yes | |.getConfigs(keys) | Provided an array of strings via the keys argument, will return an array of results in matching order as the keys. When a non-null value exists for a key, JSON.parse is attempted | Array | Yes | |.delConfig(key) | Attempts to delete string subkey of key from the hash. Missing keys produce no error | Boolean | Yes | | .hasConfigKey(key)| Checks the locally stored Set of .activeConfigKeys for a existence of a key | Boolean | No | | | .keyRefresh() | Forces a refresh of .activeConfigKeys outside of the predefined refresh intervals | undefined | Yes | | | .activeConfigKeys| Returns a Set of most recently refereshed key names | Set | No | |

source object properties

All are optional unless otherwise noted

| Property |Type| Required | Default | Description | Deprecated | |-----------|----|----------|-----------|-------------|------------| | label | String | |NO-LABEL RedisConfigManager Instance | Readable identifier for debugging. | | hashKey | String | Yup|undefined| Suffix to prepended to hashKeyPrefix | | hashKeyPrefix | String | |redis-config-manager:| Prefix for the hash key managed by this instance -- typically left as-is unless you have a pre-existing hash you want to use | | fixtureData | Object | | undefined | A simple/json-serializable object to be preloaded upon instantiation. See below for more detail.| | listeners | Object | | no-op & console | A key/function object for event listeners of debug,ready,error| | client|Object| | {host:'127.0.0.1', port:6379}| Parameters for the [node-redis](https://github.com/NodeRedis/node_redis#options-object-properties) client| |client.module_override|Function| |undefined| replaces built-inrequire('node_redis')(maybe a new branch, custom version you're using)| |client.client_override|Function| |undefined| Re-use an existingnode_redis client instance rather than using its own. (used during testing with [redis-mock](https://github.com/yeahoffline/redis-mock))| | ~~scanCount~~| String| | 1000 | Number of subkeys scanned perHSCAN- see the [count option](https://redis.io/commands/scan#the-count-option) for details | **Deprecated in v1.2.x** | |refreshInterval| Integer`| | 15000 | Number of milliseconds between key refreshes | |

Contributions & Development:

Install with dev packages and run yarn test or npm test

PRs are welcome.

###TODO: Write some todos.