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 🙏

© 2026 – Pkg Stats / Ryan Hefner

redis-odb

v0.0.4

Published

Using redis as an Object Database; an effective way to store and retrieve objects from redis.

Readme

Redis-ODB (Object Database)

Kyle Davis wrote this beautiful article on how to store objects in Redis.

I have seen at least one module inspired by this article and this is yet another.

This module inproves on the concept in sevaral important ways.

  1. Kyle talks of the shortcomings of flat and I have used dot-object which has a more superior API. Check it out.

  2. I wanted to extend the ability to fetch flattened keys i.e. 'key1.nestedkey.nestedkey2' to being able to fetch partial keys like 'key1.nestedkey.nestedkey2'. dot-object module provides a useful method '.pick' and we utilize it for such.

  3. Finally, I wanted to have the ability to fetch multiple keys at once and return a well formated partial object. Example, for an object like : {k1:1, kn:{kn2:{kn3: 300 }}, k3:3, k4:4}, it would be nice to query for ['k1','kn.kn2'] and get an object with only those values. Right?

How To

Install npm install -s redis-odb. Then go ahead and set/get objects.


const fs = require('fs');
const redisODB = require('.');

//lets use this package.json as our object
var obj = JSON.parse( fs.readFileSync('./package.json').toString() ) ;

//Set Options
let options= {
    host : '127.0.0.1',
    port : '6379',
    db : 3
}

//redis Hash Key
var key = 'TEST'; 

//Add Data to ODB
redisODB.set(key,obj, function(err, res){
    console.log(JSON.stringify(res,0,4));
    console.log('\n');
}, options );


//get a subset of the object keys....
var searchKey = ['keywords', 'dependencies' ] ;

//Get Data from ODB
redisODB.get(key, searchKey, function(err, res){    
    console.log(JSON.stringify(res,0,4));
}, options );

Outputs a partial object:


{
    "keywords": [
        "redis",
        "object",
        "database",
        "db"
    ],
    "dependencies": {
        "dot-object": "^1.5.4",
        "async": "^2.1.4",
        "redis": "^2.6.3"
    }
}

API

There are only two methods that you should worry about.

set( key, obj[, cb, options])

Save object into redis. Requires a string value that acts as the HASH KEY in redis.

get( key [, fields, cb , options])

Retrieve object from redis. Requires a string value that acts as the HASH KEY in redis.

Options

These are the same options that you would pass to node-redis.

TODO

  • Better management of redis connections. Should we close connections after every query or keep connections alive?