@mulingai-npm/redis 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ export declare enum RedisDatabase {
2
+ MULINGSTREAM_LISTENER = 0
3
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RedisDatabase = void 0;
4
+ var RedisDatabase;
5
+ (function (RedisDatabase) {
6
+ RedisDatabase[RedisDatabase["MULINGSTREAM_LISTENER"] = 0] = "MULINGSTREAM_LISTENER";
7
+ })(RedisDatabase = exports.RedisDatabase || (exports.RedisDatabase = {}));
@@ -0,0 +1,14 @@
1
+ export interface RedisConfig {
2
+ host: string;
3
+ port: number;
4
+ password?: string;
5
+ db?: number;
6
+ }
7
+ export declare class RedisClient {
8
+ private client;
9
+ constructor(config: RedisConfig);
10
+ set(key: string, value: string): Promise<void>;
11
+ get(key: string): Promise<string | null>;
12
+ flushAll(): Promise<string>;
13
+ flushDb(): Promise<string>;
14
+ }
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RedisClient = void 0;
7
+ const ioredis_1 = __importDefault(require("ioredis"));
8
+ class RedisClient {
9
+ constructor(config) {
10
+ var _a;
11
+ this.client = new ioredis_1.default({
12
+ host: config.host,
13
+ port: config.port,
14
+ password: config.password,
15
+ db: (_a = config.db) !== null && _a !== void 0 ? _a : 0
16
+ });
17
+ this.client.on('error', (err) => {
18
+ console.error('Redis error:', err);
19
+ });
20
+ }
21
+ async set(key, value) {
22
+ await this.client.set(key, value);
23
+ }
24
+ async get(key) {
25
+ return this.client.get(key);
26
+ }
27
+ // Flush ALL databases
28
+ async flushAll() {
29
+ return this.client.flushall();
30
+ }
31
+ // Flush ONLY the current database
32
+ async flushDb() {
33
+ return this.client.flushdb();
34
+ }
35
+ }
36
+ exports.RedisClient = RedisClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulingai-npm/redis",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {