Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gat-solutions/redis

Package Overview
Dependencies
Maintainers
3
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gat-solutions/redis - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "@gat-solutions/redis",
"version": "1.0.0",
"version": "1.0.1",
"description": "Custom IORedis for GAT",

@@ -5,0 +5,0 @@ "scripts": {

@@ -5,15 +5,15 @@ /** Redis Service

export declare class RedisService {
private readonly redisMasterHost;
private readonly redisMasterPort;
private readonly redisMasterPassword;
private readonly redisMasterDb;
private readonly redisSlaveHost;
private readonly redisSlavePort;
private readonly redisSlavePassword;
private readonly redisSlaveDb;
private readonly redisWriteHost;
private readonly redisWritePort;
private readonly redisWritePassword;
private readonly redisWriteDb;
private readonly redisReadHost;
private readonly redisReadPort;
private readonly redisReadPassword;
private readonly redisReadDb;
constructor();
private get masterOptions();
private get masterRedis();
private get slaveOptions();
private get slaveRedis();
private get redisWriteOptions();
private get redisWrite();
private get redisReadOptions();
private get redisRead();
/** Cache data vào redis (có thời gian hết hạn)

@@ -20,0 +20,0 @@ * @param key Tên của data trong redis

@@ -19,59 +19,59 @@ "use strict";

constructor() {
const { REDIS_MASTER_HOST, REDIS_MASTER_PORT, REDIS_MASTER_PASSWORD, REDIS_MASTER_DB, REDIS_SLAVE_HOST, REDIS_SLAVE_PORT, REDIS_SLAVE_PASSWORD, REDIS_SLAVE_DB, } = process.env;
if (!REDIS_MASTER_HOST) {
throw new Error("Missing REDIS_MASTER_HOST");
const { REDIS_WRITE_HOST, REDIS_WRITE_PORT, REDIS_WRITE_PASSWORD, REDIS_WRITE_DB, REDIS_READ_HOST, REDIS_READ_PORT, REDIS_READ_PASSWORD, REDIS_READ_DB, } = process.env;
if (!REDIS_WRITE_HOST) {
throw new Error("Missing REDIS_WRITE_HOST");
}
if (!REDIS_MASTER_PORT) {
throw new Error("Missing REDIS_MASTER_PORT");
if (!REDIS_WRITE_PORT) {
throw new Error("Missing REDIS_WRITE_PORT");
}
if (!REDIS_MASTER_PASSWORD) {
throw new Error("Missing REDIS_MASTER_PASSWORD");
if (!REDIS_WRITE_PASSWORD) {
throw new Error("Missing REDIS_WRITE_PASSWORD");
}
if (!REDIS_MASTER_DB) {
throw new Error("Missing REDIS_MASTER_DB");
if (!REDIS_WRITE_DB) {
throw new Error("Missing REDIS_WRITE_DB");
}
if (!REDIS_SLAVE_HOST) {
throw new Error("Missing REDIS_SLAVE_HOST");
if (!REDIS_READ_HOST) {
throw new Error("Missing REDIS_READ_HOST");
}
if (!REDIS_SLAVE_PORT) {
throw new Error("Missing REDIS_SLAVE_PORT");
if (!REDIS_READ_PORT) {
throw new Error("Missing REDIS_READ_PORT");
}
if (!REDIS_SLAVE_PASSWORD) {
throw new Error("Missing REDIS_SLAVE_PASSWORD");
if (!REDIS_READ_PASSWORD) {
throw new Error("Missing REDIS_READ_PASSWORD");
}
if (!REDIS_SLAVE_DB) {
throw new Error("Missing REDIS_SLAVE_DB");
if (!REDIS_READ_DB) {
throw new Error("Missing REDIS_READ_DB");
}
this.redisMasterHost = REDIS_MASTER_HOST;
this.redisMasterPort = REDIS_MASTER_PORT;
this.redisMasterPassword = REDIS_MASTER_PASSWORD;
this.redisMasterDb = REDIS_MASTER_DB;
this.redisSlaveHost = REDIS_SLAVE_HOST;
this.redisSlavePort = REDIS_SLAVE_PORT;
this.redisSlavePassword = REDIS_SLAVE_PASSWORD;
this.redisSlaveDb = REDIS_SLAVE_DB;
this.redisWriteHost = REDIS_WRITE_HOST;
this.redisWritePort = REDIS_WRITE_PORT;
this.redisWritePassword = REDIS_WRITE_PASSWORD;
this.redisWriteDb = REDIS_WRITE_DB;
this.redisReadHost = REDIS_READ_HOST;
this.redisReadPort = REDIS_READ_PORT;
this.redisReadPassword = REDIS_READ_PASSWORD;
this.redisReadDb = REDIS_READ_DB;
}
get masterOptions() {
get redisWriteOptions() {
const options = {
host: this.redisMasterHost,
port: +this.redisMasterPort,
password: this.redisMasterPassword,
db: +this.redisMasterDb,
host: this.redisWriteHost,
port: +this.redisWritePort,
password: this.redisWritePassword,
db: +this.redisWriteDb,
};
return options;
}
get masterRedis() {
return new ioredis_1.Redis(this.masterOptions);
get redisWrite() {
return new ioredis_1.Redis(this.redisWriteOptions);
}
get slaveOptions() {
get redisReadOptions() {
const options = {
host: this.redisSlaveHost,
port: +this.redisSlavePort,
password: this.redisSlavePassword,
db: +this.redisSlaveDb,
host: this.redisReadHost,
port: +this.redisReadPort,
password: this.redisReadPassword,
db: +this.redisReadDb,
};
return options;
}
get slaveRedis() {
return new ioredis_1.Redis(this.slaveOptions);
get redisRead() {
return new ioredis_1.Redis(this.redisReadOptions);
}

@@ -87,3 +87,3 @@ /** Cache data vào redis (có thời gian hết hạn)

yield this.del(key);
return this.masterRedis.set(key, value, "EX", expired);
return this.redisWrite.set(key, value, "EX", expired);
});

@@ -99,3 +99,3 @@ }

yield this.del(key);
return this.masterRedis.setnx(key, value);
return this.redisWrite.setnx(key, value);
});

@@ -108,3 +108,3 @@ }

get(key) {
return this.slaveRedis.get(key);
return this.redisRead.get(key);
}

@@ -116,3 +116,3 @@ /** Xóa data cache trong redis

del(key) {
return this.masterRedis.del(key);
return this.redisWrite.del(key);
}

@@ -124,5 +124,5 @@ /** Lấy danh sách key theo prefix

keys(prefix) {
return this.slaveRedis.keys(`${prefix}:*`);
return this.redisRead.keys(`${prefix}:*`);
}
}
exports.RedisService = RedisService;
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