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

@dekproject/redis

v2.1.2

Published

Redis interface plugin for DEK

Downloads

29

Readme

@dekproject/redis

Redis interface plugin for DEK

What does this plugin do?

  • Control configuration for connection to RabbitMQ in production development mode in a simplified way with dotenv
  • Performs connection implementation along the lines ES6 being pre requirement to start the project
  • Compressed storage functions using Snappy
  • Load balance for queries on multiple connections

Instalation

To install the bootstrap we recommend using the CLI

$ yarn add @dekproject/redis --save

In the .env file add the following settings

REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_FAMILY=4 // 4 (IPv4) or 6 (IPv6)
REDIS_PASSWORD=
REDIS_DB=0

or

REDIS_URI=localhost:6379

Load Balance

To configure loadbalance just configure a list of settings separated by commas

REDIS_SLAVES=localhost:6379,localhost:6380,localhost:6381
import { app, redis, redislb } from "@dekproject/scope";

$.wait(["redislb"]).then(async () => {
    console.time("Loading Load Balance");

    //Load Balance 
    await redislb.getSlave().set("foo3", "bar3");
    let result = await redislb.getSlave().get("foo3");
    console.log(result);

    console.timeLog("Loading Load Balance");
});

Usage

Using in the standard DEK skeleton

import { app, redis, redislb } from "@dekproject/scope";
$.wait(["redis", "redislb"]).then(async () => {
    console.time("Loading");

    //Get/Set
    await $.redis.set("foo", "bar");
    let result = await $.redis.get("foo");
    console.log({ result });

    console.timeLog("Loading");
    console.time("Loading Compress");

    //Compress String
    await $.redis.setCompress("foo2", "bar2");
    let result2 = await $.redis.getCompress("foo2", { json: false });
    console.log({ result2 });

    //Compress Object
    await $.redis.setCompress("foo3", { bar: "bar3" });
    let result3 = await $.redis.getCompress("foo3");
    console.log({ result3 });

    console.timeLog("Loading Compress");
    console.time("Loading Load Balance");

    //Load Balance 
    await $.redislb.getSlave().set("foo4", "bar4");
    let result4 = await $.redislb.getSlave().get("foo4");
    console.log({ result4 });

    console.timeLog("Loading Load Balance");

    console.time("Writing on the master and reading the slaves");
    //Writing on the master and reading the slaves
    await $.redis.set("foo5", "bar4");
    let result5 = await $.redislb.getSlave().get("foo5");
    console.log({ result5 });

    console.timeLog("Writing on the master and reading the slaves");

    console.time("Writing on the master and reading the slaves Compress");
    //Writing on the master and reading the slaves mode Compress
    await $.redis.setCompress("foo6", [{ bar: "bar6" }]);
    let result6 = await $.redislb.getSlave().getCompress("foo6");
    console.log({ result6 });
    console.timeLog("Writing on the master and reading the slaves Compress");

    console.time("Writing on the master and reading the slaves Compress with expiryMode");
    //Writing on the master and reading the slaves mode Compress
    await $.redis.setCompress("foo7", [{ bar: "bar7" }], "EX", 10);
    let result7 = await $.redislb.getSlave().getCompress("foo7");
    console.log({ result7 });
    console.timeLog("Writing on the master and reading the slaves Compress");

    console.time("getCompress null");
    let result8 = await $.redis.getCompress("foo8");
    console.log({ result8 });
    console.timeLog("getCompress null");
});