@@ -41,6 +41,23 @@ function sleep(ms: number): Promise<void> {
4141 // await cli.auth("hello");
4242 await cli . flushAll ( ) ;
4343
44+ await cli . set ( 'getex-test' , 'hello' ) ;
45+
46+ console . log ( await cli . getEx ( 'getex-test' , 1000 ) ) ;
47+ console . log ( await cli . ttl ( 'getex-test' ) ) ;
48+
49+ await cli . getPEx ( 'getex-test' , 1000 ) ;
50+ console . log ( await cli . pTTL ( 'getex-test' ) ) ;
51+
52+ await cli . getExAt ( 'getex-test' , Math . floor ( Date . now ( ) / 1000 ) + 30 ) ;
53+ console . log ( await cli . ttl ( 'getex-test' ) ) ;
54+
55+ await cli . getPExAt ( 'getex-test' , Date . now ( ) + 1000 ) ;
56+ console . log ( await cli . pTTL ( 'getex-test' ) ) ;
57+
58+ await cli . getAndPersist ( 'getex-test' ) ;
59+ console . log ( await cli . ttl ( 'getex-test' ) ) ;
60+
4461 console . log ( await cli . hRandField ( 'aaaa' , 1 ) ) ;
4562
4663 console . log ( await cli . hRandField ( 'aaaa' , 2 ) ) ;
@@ -78,16 +95,17 @@ function sleep(ms: number): Promise<void> {
7895
7996 await sleep ( 2000 ) ;
8097
81- let x = cli . set ( 'a' , '333' ) ;
98+ const x = cli . set ( 'a' , '333' ) ;
8299
83100 console . log ( 'SET ->' , await x ) ;
84101 console . log ( 'LPUSH ->' , await cli . lPush ( 'lll' , [ 'a' , 'b' ] ) ) ;
85102 console . log ( 'LINDEX ->' , await cli . lIndex ( 'lll' , 1 ) ) ;
86103 console . log ( 'LRANGE ->' , await cli . lRange ( 'lll' , 0 , - 1 ) ) ;
87- console . log ( 'HMSET->' , await cli . hMSet ( 'ggg' , {
104+ console . log ( 'HMSET->' ) ;
105+ await cli . hMSet ( 'ggg' , {
88106 'a' : '3333' ,
89107 'bb' : '1231232131'
90- } ) ) ;
108+ } ) ;
91109 console . log ( 'HMGET->' , await cli . hMGet ( 'ggg' , [ 'bb' , 'a' ] ) ) ;
92110 console . log ( 'INCR->' , await cli . incr ( 'a' ) ) ;
93111 console . log ( 'PUBSUBCHANNELS->' , await cli . pubSubChannels ( ) ) ;
@@ -99,52 +117,57 @@ function sleep(ms: number): Promise<void> {
99117
100118 await sleep ( 2000 ) ;
101119
102- const pipeline = await cli . multi ( ) ;
120+ const multiTrx = await cli . multi ( ) ;
103121
104122 // Multi Mode
105- await pipeline . multi ( ) ;
106- await pipeline . get ( 'a' ) ;
123+ await multiTrx . multi ( ) ;
124+ await multiTrx . get ( 'a' ) ;
107125
108- await pipeline . set ( 'ccc' , 'g' ) ;
126+ await multiTrx . set ( 'ccc' , 'g' ) ;
109127
110- await pipeline . mGet ( [ 'a' , 'ccc' ] ) ;
128+ await multiTrx . mGet ( [ 'a' , 'ccc' ] ) ;
111129
112- await pipeline . hSet ( 'h' , 'name' , 'Mick' ) ;
113- await pipeline . hMSet ( 'h' , {
130+ await multiTrx . hSet ( 'h' , 'name' , 'Mick' ) ;
131+ await multiTrx . hMSet ( 'h' , {
114132 'age' : 123 ,
115133 'title' : 'Mr.'
116134 } ) ;
117135
118- await pipeline . hMGet ( 'h' , [ 'age' , 'title' ] ) ;
119- await pipeline . hGetAll ( 'h' ) ;
120- console . log ( JSON . stringify ( await pipeline . scan ( 0 ) , null , 2 ) ) ;
136+ await multiTrx . hMGet ( 'h' , [ 'age' , 'title' ] ) ;
137+ await multiTrx . hGetAll ( 'h' ) ;
138+ await multiTrx . scan ( 0 ) ;
139+ // console.log(JSON.stringify(await multiTrx.scan(0), null, 2));
121140
122- await pipeline . incr ( 'a' , 123 ) ;
141+ await multiTrx . incr ( 'a' , 123 ) ;
123142
124- await pipeline . command ( 'HGETALL' , [ 'h' ] ) ;
143+ await multiTrx . command ( 'HGETALL' , [ 'h' ] ) ;
125144
126- console . log ( JSON . stringify ( await pipeline . exec ( ) , null , 2 ) ) ;
145+ console . log ( JSON . stringify ( await multiTrx . exec ( ) , null , 2 ) ) ;
146+
147+ await multiTrx . close ( ) ;
148+
149+ const pipeline = await cli . pipeline ( ) ;
127150
128151 // Pipeline Mode
129- await pipeline . get ( 'a' ) ;
152+ pipeline . get ( 'a' ) ;
130153
131- await pipeline . set ( 'ccc' , 'g' ) ;
154+ pipeline . set ( 'ccc' , 'g' ) ;
132155
133- await pipeline . mGet ( [ 'a' , 'ccc' ] ) ;
156+ pipeline . mGet ( [ 'a' , 'ccc' ] ) ;
134157
135- await pipeline . hSet ( 'h' , 'name' , 'Mick' ) ;
136- await pipeline . hMSet ( 'h' , {
158+ pipeline . hSet ( 'h' , 'name' , 'Mick' ) ;
159+ pipeline . hMSet ( 'h' , {
137160 'age' : 123 ,
138161 'title' : 'Mr.'
139162 } ) ;
140163
141- await pipeline . hMGet ( 'h' , [ 'age' , 'title' ] ) ;
142- await pipeline . hGetAll ( 'h' ) ;
143- console . log ( JSON . stringify ( await pipeline . scan ( 0 ) , null , 2 ) ) ;
164+ pipeline . hMGet ( 'h' , [ 'age' , 'title' ] ) ;
165+ pipeline . hGetAll ( 'h' ) ;
166+ pipeline . scan ( 0 ) ;
144167
145- await pipeline . incr ( 'a' , 123 ) ;
168+ pipeline . incr ( 'a' , 123 ) ;
146169
147- await pipeline . command ( 'HGETALL' , [ 'h' ] ) ;
170+ // pipeline.command('HGETALL', ['h']);
148171
149172 console . log ( JSON . stringify ( await pipeline . exec ( ) , null , 2 ) ) ;
150173
@@ -153,4 +176,4 @@ function sleep(ms: number): Promise<void> {
153176 await cli . close ( ) ;
154177 await sub . close ( ) ;
155178
156- } ) ( ) . catch ( ( e ) => console . error ( e ) ) ;
179+ } ) ( ) . catch ( console . error ) ;
0 commit comments