Socket
Book a DemoInstallSign in
Socket

@joaootavios/redis-map

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@joaootavios/redis-map

A simple way to use something similar to the Map in javascript, but synchronized with the power of Redis.

unpublished
Source
npmnpm
Version
1.0.6
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Informações

A simple way to use something similar to the Map in javascript, but synchronized with the power of Redis.

Install

npm install @joaootavios/redis-map

Example of usage

Machine 01;

const RedisMap = require("@joaootavios/redis-map");

const mapInstance = new RedisMap({ name: "my_map", url: REDIS_URL, monitor: (type, message) => {
    console.log(`Monitor: ${type} - ${message}`);
  }
});

// connect to redis to start using the map
await mapInstance.connect();
await mapInstance.set("joaootavios", { plan: "rich", age: 999, power: "god" });
await mapInstance.set("batman", { plan: "?", age: "?" }, 10); // expire in 10 seconds;

console.log(mapInstance.get("joaootavios"));

Machine 02;

const RedisMap = require("@joaootavios/redis-map");
const mapInstance = new RedisMap({ name: "my_map", url: REDIS_URL });

// connect to redis to start using the map
await mapInstance.connect();
console.log(mapInstance.get("joaootavios"));

Options

To initialize the RedisMap class, you can use the following options:

const RedisMap = require("@joaootavios/redis-map");

const options = {
  name: "my_map",
  url: "redis://localhost:6379",
  autoConnect: true, // default: false
  syncOnConnect: false, // default: true
  redisOptions: {},
  monitor: (type, message) => {
    console.log(`Monitor: ${type} - ${message}`);
  },
};

const myMap = new RedisMap(options);

LICENSE

This project is licensed under the Apache License 2.0

Keywords

redis

FAQs

Package last updated on 08 Jun 2023

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