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

oncedb-client

v0.0.1

Published

OnceDB client library

Downloads

5

Readme

oncedb-client - a node.js oncedb client

This is a complete Redis client for node.js. It supports all Redis commands, including many recently added commands like EVAL from experimental Redis server branches.

Install with:

npm install oncedb-client

Pieter Noordhuis has provided a binding to the official hiredis C library, which is non-blocking and fast. To use hiredis, do:

npm install hiredis oncedb-client

If hiredis is installed, node_redis will use it by default. Otherwise, a pure JavaScript parser will be used.

If you use hiredis, be sure to rebuild it whenever you upgrade your version of node. There are mysterious failures that can happen between node and native code modules after a node upgrade.

Usage

Simple example, included as examples/simple.js:

    var client = require("oncedb-client").createClient();

    // if you'd like to select database 3, instead of 0 (default), call
    // client.select(3, function() { /* ... */ });

    client.on("error", function (err) {
        console.log("Error " + err);
    });

    client.set("string key", "string val", oncedb.print);
    client.hset("hash key", "hashtest 1", "some value", oncedb.print);
    client.hset(["hash key", "hashtest 2", "some other value"], oncedb.print);
    client.hkeys("hash key", function (err, replies) {
        console.log(replies.length + " replies:");
        replies.forEach(function (reply, i) {
            console.log("    " + i + ": " + reply);
        });
        client.quit();
    });

This will display:

mjr:~/work/node_redis (master)$ node example.js
Reply: OK
Reply: 0
Reply: 0
2 replies:
    0: hashtest 1
    1: hashtest 2
mjr:~/work/node_redis (master)$

More

client.search('text*', '=', 'Kris', function(err, objs) {
  console.log(objs)
})

> [ 'text1', 'Kris' ] 

client.search('text*', '~', 'Kris', function(err, objs) {
  console.log(objs)
})

> [ 'text1', 'Kris', 'text5', 'This is ok, Kris' ]


client.hsearch('userInfo:*', {'nVisit': {'$gt': 300}}, function(err, objs) {
  console.log(objs)

})

client.hsearch('userInfo:*', {'nVisit': {'>': 300}}, function(err, objs) {
  console.log(objs)
})

 [ { _key: 'userInfo:1004', nVisit: '400' },
   { _key: 'userInfo:1005', nVisit: '10000' },
   { _key: 'userInfo:1006', nVisit: '10000' } ] }



client.hsearch('userInfo:*', {
    'name'     : '*'
  , 'gender'   : '*'
  , 'nVisit'   : {'>'  : '100'}
  , 'content'  : {'~|' : 'libs.min.js'}
}, function(err, objs) {
    console.log(objs)  
})

> [ { _key: 'userInfo:1006',
   name: 'Mar',
   gender: 'male',
   nVisit: '10000',
   content: ':0 0 60px 0"> <p style="float:left;line-height: 30px;"> 沪ICP备13020027号-2 </p> <p style="text-align           :right;"> <a class="btn" href="#top">返回顶部</a>  </p> </div> </div></div><script src="/js/libs.min.js"></script><scr           ipt src="/js/prod.min.js?v=219"></script><script>' } ]


client.hselect(['name'], ['userInfo:100'], function(err, objs) {
  console.log(objs)
})

> [ { _key: 'userInfo:100', name: 'shanghai' } ]



client.hselect(
    ['name', 'email', 'isPublic', 'nVisit']
  , ['userInfo:100', 'userInfo:103', 'userInfo:1005', 'userInfo:1006']
  , function(err, objs) {
    console.log(objs)
})

[ { _key: 'userInfo:100',
    name: 'shanghai',
    email: null,
    isPublic: null,
    nVisit: null },
{ _key: 'userInfo:103',
    name: 'newghost',
    email: null,
    isPublic: null,
    nVisit: null },
{ _key: 'userInfo:1005',
    name: 'Mars2',
    email: null,
    isPublic: '0',
    nVisit: '10000' },
{ _key: 'userInfo:1006',
    name: 'Mar',
    email: null,
    isPublic: '1',
    nVisit: '10000' } ]



client.hmgetall(['userInfo:100', 'userInfo:1003', 'userInfo:100'], function(err, objs) {
  console.log(objs)
})

> [ { _key: 'userInfo:100',
    id: '100',
    name: 'shanghai',
    gender: 'female',
    poster: '龙' },
  { _key: 'userInfo:1003',
    name: 'Telyer',
    id: '1003',
    gender: 'male',
    active: '0',
    joinTime: '1484445746020',
    poster: '王五',
    isPublic: '0',
    nVisit: '300' },
  { _key: 'userInfo:100',
    id: '100',
    name: 'shanghai',
    gender: 'female',
    poster: '龙' } ]

About

It's fork from https://github.com/NodeRedis/node_redis/tree/v0.12.1