1 |
|
2 | import { EventEmitter } from 'events';
|
3 | import Transaction from './transaction';
|
4 | import Batch from './batch';
|
5 | import { IRedisKeyOptions } from './types/redis';
|
6 | export interface IRedisOptions {
|
7 | host: string;
|
8 | port: number;
|
9 | prefix?: string;
|
10 | }
|
11 | declare class Redis extends EventEmitter {
|
12 | private _client;
|
13 | private _prefix;
|
14 | |
15 |
|
16 |
|
17 | constructor(options: IRedisOptions);
|
18 | /**
|
19 | * Get the underlying redis client
|
20 | */
|
21 | readonly client: any;
|
22 | /**
|
23 | * Close the client
|
24 | */
|
25 | dispose(): Promise<void>;
|
26 | /**
|
27 | * Return the transaction prototype
|
28 | */
|
29 | static readonly Transaction: typeof Transaction;
|
30 | /**
|
31 | * Get a transaction
|
32 | */
|
33 | transaction(): Transaction;
|
34 | /**
|
35 | * Watch a key
|
36 | */
|
37 | watch(key: string): Promise<void>;
|
38 | /**
|
39 | * Begin a batch of commands
|
40 | */
|
41 | batch(): Batch;
|
42 | /**
|
43 | * Key exists
|
44 | */
|
45 | exists(key: string): Promise<boolean>;
|
46 | /**
|
47 | * Get a key value
|
48 | */
|
49 | get(key: string): Promise<string>;
|
50 | /**
|
51 | * Set a key value
|
52 | */
|
53 | set(key: string, value: string | number, options?: IRedisKeyOptions): Promise<void>;
|
54 | /**
|
55 | * Increment an integer value
|
56 | */
|
57 | incrby(key: string, value: number, options?: IRedisKeyOptions): Promise<void>;
|
58 | /**
|
59 | * Increment a float value
|
60 | */
|
61 | incrbyfloat(key: string, value: number, options?: IRedisKeyOptions): Promise<void>;
|
62 | /**
|
63 | * Increment an integer value in a hash set
|
64 | */
|
65 | hincrby(key: string, hashKey: string, value: number, options?: IRedisKeyOptions): Promise<void>;
|
66 | /**
|
67 | * Increment a float value in a hash set
|
68 | */
|
69 | hincrbyfloat(key: string, hashKey: string, value: number, options?: IRedisKeyOptions): Promise<void>;
|
70 | /**
|
71 | * Hash map set
|
72 | */
|
73 | hmset(key: string, hash: object, options?: IRedisKeyOptions): Promise<void>;
|
74 | /**
|
75 | * Get a hash set
|
76 | */
|
77 | hgetall(key: string): Promise<any>;
|
78 | /**
|
79 | * Delete a key
|
80 | */
|
81 | del(key: string): Promise<void>;
|
82 | /**
|
83 | * Add to a set
|
84 | */
|
85 | sadd(key: string, value: string | number | Array<string | number>, options?: IRedisKeyOptions): Promise<void>;
|
86 | /**
|
87 | * Get a set
|
88 | */
|
89 | smembers(key: any): Promise<string[]>;
|
90 | /**
|
91 | * Remove from set
|
92 | */
|
93 | srem(key: string, value: string | number): Promise<void>;
|
94 | /**
|
95 | * Scan and delete keys
|
96 | */
|
97 | scanDel(pattern: string): Promise<void>;
|
98 | /**
|
99 | * Scan keys
|
100 | */
|
101 | scan(pattern: string, delegate: (keys: string[]) => Promise<void> | void): Promise<void>;
|
102 | /**
|
103 | * Get the remaining time of a key
|
104 | */
|
105 | ttl(key: any): Promise<number>;
|
106 | /**
|
107 | * Set the expiry in seconds
|
108 | */
|
109 | private _checkExpiry(key, options);
|
110 | /**
|
111 | * Check to make sure this transaction is still open
|
112 | */
|
113 | private _checkDisposed();
|
114 | }
|
115 | export default Redis;
|