@@ -2432,152 +2432,149 @@ var _ = Describe("Commands", func() {
2432
2432
})
2433
2433
2434
2434
It ("should HExpire" , Label ("hash-expiration" ), func () {
2435
- //redis client with port 6379
2436
- client1 := redis .NewClient (& redis.Options {Addr : "localhost:6379" })
2437
- res , err := client1 .HExpire (ctx , "no_such_key" , 10 , "field1" , "field2" , "field3" ).Result ()
2438
- Expect (err ).To (HaveOccurred ())
2435
+ res , err := client .HExpire (ctx , "no_such_key" , 10 , "field1" , "field2" , "field3" ).Result ()
2436
+ Expect (err ).To (BeNil ())
2439
2437
for i := 0 ; i < 100 ; i ++ {
2440
- sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2438
+ sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2441
2439
Expect (sadd .Err ()).NotTo (HaveOccurred ())
2442
2440
}
2443
2441
2444
- res , err = client1 .HExpire (ctx , "myhash" , 10 , "key1" , "key2" , "key200" ).Result ()
2442
+ res , err = client .HExpire (ctx , "myhash" , 10 , "key1" , "key2" , "key200" ).Result ()
2445
2443
Expect (err ).NotTo (HaveOccurred ())
2446
2444
Expect (res ).To (Equal ([]int64 {1 , 1 , - 2 }))
2447
2445
})
2448
2446
2449
2447
It ("should HPExpire" , Label ("hash-expiration" ), func () {
2450
- client1 := redis .NewClient (& redis.Options {Addr : "localhost:6379" })
2451
- _ , err := client1 .HPExpire (ctx , "no_such_key" , 10 , "field1" , "field2" , "field3" ).Result ()
2452
- Expect (err ).To (HaveOccurred ())
2448
+ _ , err := client .HPExpire (ctx , "no_such_key" , 10 , "field1" , "field2" , "field3" ).Result ()
2449
+ Expect (err ).To (BeNil ())
2453
2450
for i := 0 ; i < 100 ; i ++ {
2454
- sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2451
+ sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2455
2452
Expect (sadd .Err ()).NotTo (HaveOccurred ())
2456
2453
}
2457
2454
2458
- res , err := client1 .HPExpire (ctx , "myhash" , 10 , "key1" , "key2" , "key200" ).Result ()
2455
+ res , err := client .HPExpire (ctx , "myhash" , 10 , "key1" , "key2" , "key200" ).Result ()
2459
2456
Expect (err ).NotTo (HaveOccurred ())
2460
2457
Expect (res ).To (Equal ([]int64 {1 , 1 , - 2 }))
2461
2458
})
2462
2459
2463
2460
It ("should HExpireAt" , Label ("hash-expiration" ), func () {
2464
- client1 := redis . NewClient ( & redis. Options { Addr : "localhost:6379" })
2465
- _ , err := client1 .HExpireAt (ctx , "no_such_key" , time .Now ().Add (10 * time .Second ), "field1" , "field2" , "field3" ).Result ()
2466
- Expect (err ).To (HaveOccurred ())
2461
+
2462
+ _ , err := client .HExpireAt (ctx , "no_such_key" , time .Now ().Add (10 * time .Second ), "field1" , "field2" , "field3" ).Result ()
2463
+ Expect (err ).To (BeNil ())
2467
2464
for i := 0 ; i < 100 ; i ++ {
2468
- sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2465
+ sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2469
2466
Expect (sadd .Err ()).NotTo (HaveOccurred ())
2470
2467
}
2471
2468
2472
- res , err := client1 .HExpireAt (ctx , "myhash" , time .Now ().Add (10 * time .Second ), "key1" , "key2" , "key200" ).Result ()
2469
+ res , err := client .HExpireAt (ctx , "myhash" , time .Now ().Add (10 * time .Second ), "key1" , "key2" , "key200" ).Result ()
2473
2470
Expect (err ).NotTo (HaveOccurred ())
2474
2471
Expect (res ).To (Equal ([]int64 {1 , 1 , - 2 }))
2475
2472
})
2476
2473
2477
2474
It ("should HPExpireAt" , Label ("hash-expiration" ), func () {
2478
- client1 := redis . NewClient ( & redis. Options { Addr : "localhost:6379" })
2479
- _ , err := client1 .HPExpireAt (ctx , "no_such_key" , time .Now ().Add (10 * time .Second ), "field1" , "field2" , "field3" ).Result ()
2480
- Expect (err ).To (HaveOccurred ())
2475
+
2476
+ _ , err := client .HPExpireAt (ctx , "no_such_key" , time .Now ().Add (10 * time .Second ), "field1" , "field2" , "field3" ).Result ()
2477
+ Expect (err ).To (BeNil ())
2481
2478
for i := 0 ; i < 100 ; i ++ {
2482
- sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2479
+ sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2483
2480
Expect (sadd .Err ()).NotTo (HaveOccurred ())
2484
2481
}
2485
2482
2486
- res , err := client1 .HPExpireAt (ctx , "myhash" , time .Now ().Add (10 * time .Second ), "key1" , "key2" , "key200" ).Result ()
2483
+ res , err := client .HPExpireAt (ctx , "myhash" , time .Now ().Add (10 * time .Second ), "key1" , "key2" , "key200" ).Result ()
2487
2484
Expect (err ).NotTo (HaveOccurred ())
2488
2485
Expect (res ).To (Equal ([]int64 {1 , 1 , - 2 }))
2489
2486
})
2490
2487
2491
2488
It ("should HPersist" , Label ("hash-expiration" ), func () {
2492
- client1 := redis . NewClient ( & redis. Options { Addr : "localhost:6379" })
2493
- _ , err := client1 .HPersist (ctx , "no_such_key" , "field1" , "field2" , "field3" ).Result ()
2494
- Expect (err ).To (HaveOccurred ())
2489
+
2490
+ _ , err := client .HPersist (ctx , "no_such_key" , "field1" , "field2" , "field3" ).Result ()
2491
+ Expect (err ).To (BeNil ())
2495
2492
for i := 0 ; i < 100 ; i ++ {
2496
- sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2493
+ sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2497
2494
Expect (sadd .Err ()).NotTo (HaveOccurred ())
2498
2495
}
2499
2496
2500
- res , err := client1 .HPersist (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2497
+ res , err := client .HPersist (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2501
2498
Expect (err ).NotTo (HaveOccurred ())
2502
2499
Expect (res ).To (Equal ([]int64 {- 1 , - 1 , - 2 }))
2503
2500
2504
- res , err = client1 .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
2501
+ res , err = client .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
2505
2502
Expect (err ).NotTo (HaveOccurred ())
2506
2503
Expect (res ).To (Equal ([]int64 {1 , - 2 }))
2507
2504
2508
- res , err = client1 .HPersist (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2505
+ res , err = client .HPersist (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2509
2506
Expect (err ).NotTo (HaveOccurred ())
2510
2507
Expect (res ).To (Equal ([]int64 {1 , - 1 , - 2 }))
2511
2508
})
2512
2509
2513
2510
It ("should HExpireTime" , Label ("hash-expiration" ), func () {
2514
- client1 := redis . NewClient ( & redis. Options { Addr : "localhost:6379" })
2515
- _ , err := client1 .HExpireTime (ctx , "no_such_key" , "field1" , "field2" , "field3" ).Result ()
2516
- Expect (err ).To (HaveOccurred ())
2511
+
2512
+ _ , err := client .HExpireTime (ctx , "no_such_key" , "field1" , "field2" , "field3" ).Result ()
2513
+ Expect (err ).To (BeNil ())
2517
2514
for i := 0 ; i < 100 ; i ++ {
2518
- sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2515
+ sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2519
2516
Expect (sadd .Err ()).NotTo (HaveOccurred ())
2520
2517
}
2521
2518
2522
- res , err := client1 .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
2519
+ res , err := client .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
2523
2520
Expect (err ).NotTo (HaveOccurred ())
2524
2521
Expect (res ).To (Equal ([]int64 {1 , - 2 }))
2525
2522
2526
- res , err = client1 .HExpireTime (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2523
+ res , err = client .HExpireTime (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2527
2524
Expect (err ).NotTo (HaveOccurred ())
2528
2525
Expect (res [0 ]).To (BeNumerically ("~" , time .Now ().Add (10 * time .Second ).Unix (), 1 ))
2529
2526
})
2530
2527
2531
2528
It ("should HPExpireTime" , Label ("hash-expiration" ), func () {
2532
- client1 := redis . NewClient ( & redis. Options { Addr : "localhost:6379" })
2533
- _ , err := client1 .HPExpireTime (ctx , "no_such_key" , "field1" , "field2" , "field3" ).Result ()
2534
- Expect (err ).To (HaveOccurred ())
2529
+
2530
+ _ , err := client .HPExpireTime (ctx , "no_such_key" , "field1" , "field2" , "field3" ).Result ()
2531
+ Expect (err ).To (BeNil ())
2535
2532
for i := 0 ; i < 100 ; i ++ {
2536
- sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2533
+ sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2537
2534
Expect (sadd .Err ()).NotTo (HaveOccurred ())
2538
2535
}
2539
2536
2540
- res , err := client1 .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
2537
+ res , err := client .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
2541
2538
Expect (err ).NotTo (HaveOccurred ())
2542
2539
Expect (res ).To (Equal ([]int64 {1 , - 2 }))
2543
2540
2544
- res , err = client1 .HPExpireTime (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2541
+ res , err = client .HPExpireTime (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2545
2542
Expect (err ).NotTo (HaveOccurred ())
2546
2543
Expect (res ).To (BeEquivalentTo ([]int64 {time .Now ().Add (10 * time .Second ).UnixMilli (), - 1 , - 2 }))
2547
2544
})
2548
2545
2549
2546
It ("should HTTL" , Label ("hash-expiration" ), func () {
2550
- client1 := redis . NewClient ( & redis. Options { Addr : "localhost:6379" })
2551
- _ , err := client1 .HTTL (ctx , "no_such_key" , "field1" , "field2" , "field3" ).Result ()
2552
- Expect (err ).To (HaveOccurred ())
2547
+
2548
+ _ , err := client .HTTL (ctx , "no_such_key" , "field1" , "field2" , "field3" ).Result ()
2549
+ Expect (err ).To (BeNil ())
2553
2550
for i := 0 ; i < 100 ; i ++ {
2554
- sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2551
+ sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2555
2552
Expect (sadd .Err ()).NotTo (HaveOccurred ())
2556
2553
}
2557
2554
2558
- res , err := client1 .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
2555
+ res , err := client .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
2559
2556
Expect (err ).NotTo (HaveOccurred ())
2560
2557
Expect (res ).To (Equal ([]int64 {1 , - 2 }))
2561
2558
2562
- res , err = client1 .HTTL (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2559
+ res , err = client .HTTL (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2563
2560
Expect (err ).NotTo (HaveOccurred ())
2564
2561
Expect (res ).To (Equal ([]int64 {10 , - 1 , - 2 }))
2565
2562
})
2566
2563
2567
2564
It ("should HPTTL" , Label ("hash-expiration" ), func () {
2568
- client1 := redis . NewClient ( & redis. Options { Addr : "localhost:6379" })
2569
- _ , err := client1 .HPTTL (ctx , "no_such_key" , "field1" , "field2" , "field3" ).Result ()
2570
- Expect (err ).To (HaveOccurred ())
2565
+
2566
+ _ , err := client .HPTTL (ctx , "no_such_key" , "field1" , "field2" , "field3" ).Result ()
2567
+ Expect (err ).To (BeNil ())
2571
2568
for i := 0 ; i < 100 ; i ++ {
2572
- sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2569
+ sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2573
2570
Expect (sadd .Err ()).NotTo (HaveOccurred ())
2574
2571
}
2575
2572
2576
- res , err := client1 .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
2573
+ res , err := client .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
2577
2574
Expect (err ).NotTo (HaveOccurred ())
2578
2575
Expect (res ).To (Equal ([]int64 {1 , - 2 }))
2579
2576
2580
- res , err = client1 .HPTTL (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2577
+ res , err = client .HPTTL (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2581
2578
Expect (err ).NotTo (HaveOccurred ())
2582
2579
Expect (res [0 ]).To (BeNumerically ("~" , 10 * time .Second .Milliseconds (), 1 ))
2583
2580
})
0 commit comments