@mulingai-npm/redis 1.2.4 → 1.2.5

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.
@@ -46,6 +46,7 @@ class RedisClient {
46
46
  }
47
47
  // flush methods
48
48
  async flushAll() {
49
+ console.log('Removing all data!');
49
50
  return this.client.flushall();
50
51
  }
51
52
  async flushDb() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulingai-npm/redis",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {
package/dist/index.d.ts DELETED
@@ -1,19 +0,0 @@
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
- hset(key: string, data: Record<string, string>): Promise<number>;
13
- hgetall(key: string): Promise<Record<string, string>>;
14
- sadd(key: string, ...values: string[]): Promise<number>;
15
- smembers(key: string): Promise<string[]>;
16
- keys(pattern: string): Promise<string[]>;
17
- flushAll(): Promise<string>;
18
- flushDb(): Promise<string>;
19
- }
package/dist/index.js DELETED
@@ -1,56 +0,0 @@
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
- // redis-client.ts
8
- const ioredis_1 = __importDefault(require("ioredis"));
9
- class RedisClient {
10
- constructor(config) {
11
- this.client = new ioredis_1.default({
12
- host: config.host,
13
- port: config.port,
14
- password: config.password,
15
- db: config.db
16
- });
17
- this.client.on('error', (err) => {
18
- console.error('Redis error:', err);
19
- });
20
- }
21
- // existing set/get
22
- async set(key, value) {
23
- await this.client.set(key, value);
24
- }
25
- async get(key) {
26
- return this.client.get(key);
27
- }
28
- // add these methods for hash, sets, keys, etc.
29
- async hset(key, data) {
30
- return this.client.hset(key, data);
31
- }
32
- async hgetall(key) {
33
- return this.client.hgetall(key);
34
- }
35
- // Insert one or more values into a set
36
- async sadd(key, ...values) {
37
- return this.client.sadd(key, values);
38
- }
39
- // Get all set members
40
- async smembers(key) {
41
- return this.client.smembers(key);
42
- }
43
- // Search for all keys matching a pattern
44
- // NOTE: If you have lots of keys in Redis, you should look into using SCAN instead of KEYS
45
- async keys(pattern) {
46
- return this.client.keys(pattern);
47
- }
48
- // flush methods
49
- async flushAll() {
50
- return this.client.flushall();
51
- }
52
- async flushDb() {
53
- return this.client.flushdb();
54
- }
55
- }
56
- exports.RedisClient = RedisClient;