@@ -8,56 +8,48 @@ import * as L from "@litert/core";
88 const cli = Redis . createCommandClient ( "127.0.0.1" , 6373 ) ;
99 const sub = Redis . createSubscriberClient ( "127.0.0.1" , 6373 ) ;
1010
11- try {
11+ await sub . connect ( ) ;
1212
13- await sub . connect ( ) ;
13+ await sub . auth ( "hello" ) ;
1414
15- await sub . auth ( "hello" ) ;
15+ sub . on ( "message" , function ( c , d , p ) : void {
1616
17- sub . on ( "message" , function ( c , d , p ) : void {
17+ console . log ( `Channel: ${ c } , Data: ${ d . toString ( ) } ` ) ;
18+ } ) ;
1819
19- console . log ( `Channel: ${ c } , Data: ${ d . toString ( ) } ` ) ;
20- } ) ;
20+ await sub . subscribe ( [ "hello" ] ) ;
2121
22- await sub . subscribe ( [ "hello" ] ) ;
22+ await cli . connect ( ) ;
23+ await cli . auth ( "hello" ) ;
24+ console . log ( await cli . ping ( "" ) ) ;
25+ console . log ( await cli . set ( "a" , "123" ) ) ;
26+ console . log ( await cli . incr ( "a" , 23 ) ) ;
27+ console . log ( await cli . incrByFloat ( "a" , 23.4 ) ) ;
28+ console . log ( await cli . get ( "a" ) ) ;
29+ console . log ( await cli . mGet ( [ "a" , "sada" ] ) ) ;
2330
24- await cli . connect ( ) ;
25- await cli . auth ( "hello" ) ;
26- console . log ( await cli . ping ( "" ) ) ;
27- console . log ( await cli . set ( "a" , "123" ) ) ;
28- console . log ( await cli . incr ( "a" , 23.4 ) ) ;
29- console . log ( await cli . get ( "a" ) ) ;
30- console . log ( await cli . mGet ( [ "a" , "sada" ] ) ) ;
31+ await L . Async . sleep ( 2000 ) ;
3132
32- await L . Async . sleep ( 2000 ) ;
33+ let x = cli . set ( "a" , "333" ) ;
3334
34- let x = cli . set ( "a" , "333" ) ;
35+ console . log ( await x ) ;
36+ await cli . lPush ( "lll" , [ "a" , "b" ] ) ;
37+ console . log ( await cli . lIndex ( "lll" , 1 ) ) ;
38+ console . log ( await cli . lRange ( "lll" , 0 , - 1 ) ) ;
39+ console . log ( await cli . hMSet ( "ggg" , {
40+ "a" : "3333" ,
41+ "bb" : "1231232131"
42+ } ) ) ;
43+ console . log ( await cli . hMGet ( "ggg" , [ "bb" , "a" ] ) ) ;
44+ console . log ( await cli . incr ( "a" ) ) ;
45+ console . log ( await cli . pubSubChannels ( ) ) ;
46+ console . log ( await cli . pubSubNumPat ( ) ) ;
47+ console . log ( await cli . pubSubNumSub ( [ "hello" ] ) ) ;
48+ console . log ( await cli . publish ( "hello" , "test" ) ) ;
3549
36- console . log ( await x ) ;
37- await cli . lPush ( "lll" , [ "a" , "b" ] ) ;
38- console . log ( await cli . lIndex ( "lll" , 1 ) ) ;
39- console . log ( await cli . lRange ( "lll" , 0 , - 1 ) ) ;
40- console . log ( await cli . hMSet ( "ggg" , {
41- "a" : "3333" ,
42- "bb" : "1231232131"
43- } ) ) ;
44- console . log ( await cli . hMGet ( "ggg" , [ "bb" , "a" ] ) ) ;
45- console . log ( await cli . incr ( "a" ) ) ;
46- console . log ( await cli . pubSubChannels ( ) ) ;
47- console . log ( await cli . pubSubNumPat ( ) ) ;
48- console . log ( await cli . pubSubNumSub ( [ "hello" ] ) ) ;
49- console . log ( await cli . publish ( "hello" , "test" ) ) ;
50-
51- await L . Async . sleep ( 2000 ) ;
52-
53- await cli . shutdown ( ) ;
54- await sub . shutdown ( ) ;
55- }
56- catch ( e ) {
57-
58- console . error ( e ) ;
59- }
50+ await L . Async . sleep ( 2000 ) ;
6051
6152 await cli . shutdown ( ) ;
53+ await sub . shutdown ( ) ;
6254
6355} ) ( ) ;
0 commit comments