New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dekproject/redis

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dekproject/redis

Redis interface plugin for DEK

  • 2.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

@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");
});

Keywords

FAQs

Package last updated on 16 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc