Comparing version 0.0.3 to 0.0.4
@@ -5,6 +5,7 @@ import { RedisClient } from "redis"; | ||
private readonly host; | ||
private readonly connectedCallback; | ||
private readonly redisClient; | ||
constructor(port: number, host: string); | ||
constructor(port: number, host: string, onConnected?: Function); | ||
private static onError; | ||
private static onConnected; | ||
private readonly onConnected; | ||
get client(): RedisClient; | ||
@@ -11,0 +12,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class RedisMgr { | ||
constructor(port, host) { | ||
constructor(port, host, onConnected = null) { | ||
this.onConnected = () => { | ||
console.log(`Redis_已经连接正常`); | ||
this.connectedCallback && this.connectedCallback(); | ||
}; | ||
this.port = port; | ||
this.host = host; | ||
this.connectedCallback = onConnected; | ||
const redis = require("redis"); | ||
this.redisClient = redis.createClient(this.port, this.host); | ||
this.redisClient.on("connect", RedisMgr.onConnected.bind(RedisMgr)); | ||
this.redisClient.on("connect", this.onConnected); | ||
this.redisClient.on("error", RedisMgr.onError.bind(RedisMgr)); | ||
@@ -15,5 +20,2 @@ } | ||
} | ||
static onConnected(data) { | ||
console.log(`\n------Redis------已经连接:${undefined === data ? "正常" : data.toString()}\n`); | ||
} | ||
get client() { | ||
@@ -20,0 +22,0 @@ return this.redisClient; |
@@ -6,8 +6,9 @@ import { RedisSubscribeHandler } from "./RedisSubscribeHandler"; | ||
private readonly redisClient; | ||
private readonly connectedCallback; | ||
private arr_channel; | ||
constructor(port: number, host: string); | ||
constructor(port: number, host: string, onConnected?: Function); | ||
private init; | ||
subscribe(channel: string, handler: RedisSubscribeHandler): void; | ||
private static onError; | ||
private static onConnected; | ||
private readonly onConnected; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class RedisSubscriber { | ||
constructor(port, host) { | ||
constructor(port, host, onConnected = null) { | ||
this.arr_channel = new Map(); | ||
this.onConnected = () => { | ||
console.log("Redis_消息订阅客户端_已经连接"); | ||
this.connectedCallback && this.connectedCallback(); | ||
}; | ||
this.port = port; | ||
this.host = host; | ||
this.connectedCallback = onConnected; | ||
const redis = require("redis"); | ||
@@ -13,3 +18,3 @@ this.redisClient = redis.createClient(this.port, this.host); | ||
init() { | ||
this.redisClient.on("connect", RedisSubscriber.onConnected.bind(RedisSubscriber)); | ||
this.redisClient.on("connect", this.onConnected); | ||
this.redisClient.on("error", RedisSubscriber.onError.bind(RedisSubscriber)); | ||
@@ -42,6 +47,3 @@ this.redisClient.on("subscribe", (channel, count) => { | ||
} | ||
static onConnected(data) { | ||
console.log("Redis_消息订阅客户端_已经连接:" + data); | ||
} | ||
} | ||
exports.RedisSubscriber = RedisSubscriber; |
{ | ||
"name": "redis_mgr", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46918
388