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

lvge-redis

v2.0.2

Published

Redis Connection Pool

Downloads

3

Readme

Redis

Redis Connection Pool

Usage:

  1. 引入模块:

    var redis = require("lvge-redis");

  2. 加载配置文件, 连接Redis:

    var config = require("./cfg/redisConf"); var pool = redis.connect_with_easy_pool(config);

  3. 使用连接池

使用String

pool.execute("set", "justin", "mimi0", "EX", 10, "NX", cb);
pool.execute("set", "justin", "mimi1", "PX", 10000, cb);
pool.execute("set", "justin", "mimi2", "NX", cb);
pool.execute("set", "justin", "mimi3", "XX", cb);
pool.execute("get", "justin", cb);

pool.execute("set", "justin", false, cb);   // 将存储成"false"字符串, true将存储成"true"字符串
pool.execute("get", "justin", cb);
pool.execute("del", "justin", cb);

使用List

pool.execute("lpush", "l_justin", "11", "22", 33, 44, cb);
pool.execute("lrange", "l_justin", 0, -1, cb);
pool.execute("del", "l_justin", cb);

var handler = ["lpush"], key = ["l_justin"], values = [1, 2, 3, 4, 5, 6];
values = handler.concat(key, values, cb);
console.log(values);
pool.execute.apply(pool, values);
pool.execute("lrange", "l_justin", 0, -1, cb);
pool.execute("del", "l_justin", cb);

使用Hash列表

pool.execute("hmset", "h_justin", {"name": "mimi", "age": 20}, cb);
pool.execute("hmset", "h_justin", "hair", "black", "glass", 1, cb);
pool.execute("hset", "h_justin", "sex", "man", cb);
pool.execute("hgetall", "h_justin", cb);
pool.execute("hdel", "h_justin", "age", cb);
pool.execute("hgetall", "h_justin", cb);
pool.execute("del", "h_justin", cb);

使用Lua脚本用例1

var hkey, k, v, skey, value;
var hincrby_positive = fs.readFileSync("hincrby_positive.lua");
var incrby_positive = fs.readFileSync("incrby_positive.lua");

hkey = "h_justin";
k = "score";
v = 300;
pool.execute("eval", hincrby_positive, 1, hkey, k, v, cb);

skey = "justin";
value = 1000;
pool.execute("eval", incrby_positive, 1, skey, value, cb);

使用Lua脚本用例2

var hkey, k, v, skey, value;

var hset_larger = fs.readFileSync("hset_larger.lua");
var set_larger = fs.readFileSync("set_larger.lua");

k = "large_score";
v = 103;
pool.execute("eval", hset_larger, 1, hkey, k, v, cb);

skey = "justin";
value = 118;
pool.execute("eval", set_larger, 1, skey, value, cb);

使用Multi

pool.multi(function (err, multi) {
    multi.set("justin", 1200);
    multi.incr("justin");
    setTimeout(function () {
        multi.get("justin");
        multi.exec(cb);
    }, 3000);
});