@@ -1104,172 +1104,6 @@ var _ = Describe("Commands", func() {
1104
1104
Expect (cursor ).NotTo (BeZero ())
1105
1105
})
1106
1106
1107
- It ("should HExpire" , func () {
1108
- res , err := client .HExpire (ctx , "no_such_key" , 10 , "field1" , "field2" , "field3" ).Result ()
1109
- Expect (err ).To (HaveOccurred ())
1110
- for i := 0 ; i < 100 ; i ++ {
1111
- sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
1112
- Expect (sadd .Err ()).NotTo (HaveOccurred ())
1113
- }
1114
-
1115
- res , err = client .HExpire (ctx , "myhash" , 10 , "key1" , "key2" , "key200" ).Result ()
1116
- Expect (err ).NotTo (HaveOccurred ())
1117
- Expect (res ).To (Equal ([]int64 {1 , 1 , - 2 }))
1118
- })
1119
-
1120
- It ("should HPExpire" , func () {
1121
- _ , err := client .HPExpire (ctx , "no_such_key" , 10 , "field1" , "field2" , "field3" ).Result ()
1122
- Expect (err ).To (HaveOccurred ())
1123
- for i := 0 ; i < 100 ; i ++ {
1124
- sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
1125
- Expect (sadd .Err ()).NotTo (HaveOccurred ())
1126
- }
1127
-
1128
- res , err := client .HPExpire (ctx , "myhash" , 10 , "key1" , "key2" , "key200" ).Result ()
1129
- Expect (err ).NotTo (HaveOccurred ())
1130
- Expect (res ).To (Equal ([]int64 {1 , 1 , - 2 }))
1131
- })
1132
-
1133
- It ("should HExpireAt" , func () {
1134
- _ , err := client .HExpireAt (ctx , "no_such_key" , time .Now ().Add (10 * time .Second ), "field1" , "field2" , "field3" ).Result ()
1135
- Expect (err ).To (HaveOccurred ())
1136
- for i := 0 ; i < 100 ; i ++ {
1137
- sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
1138
- Expect (sadd .Err ()).NotTo (HaveOccurred ())
1139
- }
1140
-
1141
- res , err := client .HExpireAt (ctx , "myhash" , time .Now ().Add (10 * time .Second ), "key1" , "key2" , "key200" ).Result ()
1142
- Expect (err ).NotTo (HaveOccurred ())
1143
- Expect (res ).To (Equal ([]int64 {1 , 1 , - 2 }))
1144
- })
1145
-
1146
- It ("should HPExpireAt" , func () {
1147
- _ , err := client .HPExpireAt (ctx , "no_such_key" , time .Now ().Add (10 * time .Second ), "field1" , "field2" , "field3" ).Result ()
1148
- Expect (err ).To (HaveOccurred ())
1149
- for i := 0 ; i < 100 ; i ++ {
1150
- sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
1151
- Expect (sadd .Err ()).NotTo (HaveOccurred ())
1152
- }
1153
-
1154
- res , err := client .HPExpireAt (ctx , "myhash" , time .Now ().Add (10 * time .Second ), "key1" , "key2" , "key200" ).Result ()
1155
- Expect (err ).NotTo (HaveOccurred ())
1156
- Expect (res ).To (Equal ([]int64 {1 , 1 , - 2 }))
1157
- })
1158
-
1159
- It ("should HPersist" , func () {
1160
- _ , err := client .HPersist (ctx , "no_such_key" , "field1" , "field2" , "field3" ).Result ()
1161
- Expect (err ).To (HaveOccurred ())
1162
- for i := 0 ; i < 100 ; i ++ {
1163
- sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
1164
- Expect (sadd .Err ()).NotTo (HaveOccurred ())
1165
- }
1166
-
1167
- res , err := client .HPersist (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
1168
- Expect (err ).NotTo (HaveOccurred ())
1169
- Expect (res ).To (Equal ([]int64 {- 1 , - 1 , - 2 }))
1170
-
1171
- res , err = client .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
1172
- Expect (err ).NotTo (HaveOccurred ())
1173
- Expect (res ).To (Equal ([]int64 {1 , - 2 }))
1174
-
1175
- res , err = client .HPersist (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
1176
- Expect (err ).NotTo (HaveOccurred ())
1177
- Expect (res ).To (Equal ([]int64 {1 , - 1 , - 2 }))
1178
- })
1179
-
1180
- It ("should HExpireTime" , func () {
1181
- _ , err := client .HExpireTime (ctx , "no_such_key" , "field1" , "field2" , "field3" ).Result ()
1182
- Expect (err ).To (HaveOccurred ())
1183
- for i := 0 ; i < 100 ; i ++ {
1184
- sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
1185
- Expect (sadd .Err ()).NotTo (HaveOccurred ())
1186
- }
1187
-
1188
- res , err := client .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
1189
- Expect (err ).NotTo (HaveOccurred ())
1190
- Expect (res ).To (Equal ([]int64 {1 , - 2 }))
1191
-
1192
- res , err = client .HExpireTime (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
1193
- Expect (err ).NotTo (HaveOccurred ())
1194
- Expect (res [0 ]).To (BeNumerically ("~" , time .Now ().Add (10 * time .Second ).Unix (), 1 ))
1195
- })
1196
-
1197
- It ("should HPExpireTime" , func () {
1198
- _ , err := client .HPExpireTime (ctx , "no_such_key" , "field1" , "field2" , "field3" ).Result ()
1199
- Expect (err ).To (HaveOccurred ())
1200
- for i := 0 ; i < 100 ; i ++ {
1201
- sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
1202
- Expect (sadd .Err ()).NotTo (HaveOccurred ())
1203
- }
1204
-
1205
- res , err := client .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
1206
- Expect (err ).NotTo (HaveOccurred ())
1207
- Expect (res ).To (Equal ([]int64 {1 , - 2 }))
1208
-
1209
- res , err = client .HPExpireTime (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
1210
- Expect (err ).NotTo (HaveOccurred ())
1211
- Expect (res ).To (BeEquivalentTo ([]int64 {time .Now ().Add (10 * time .Second ).UnixMilli (), - 1 , - 2 }))
1212
- })
1213
-
1214
- It ("should HTTL" , func () {
1215
- _ , err := client .HTTL (ctx , "no_such_key" , "field1" , "field2" , "field3" ).Result ()
1216
- Expect (err ).To (HaveOccurred ())
1217
- for i := 0 ; i < 100 ; i ++ {
1218
- sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
1219
- Expect (sadd .Err ()).NotTo (HaveOccurred ())
1220
- }
1221
-
1222
- res , err := client .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
1223
- Expect (err ).NotTo (HaveOccurred ())
1224
- Expect (res ).To (Equal ([]int64 {1 , - 2 }))
1225
-
1226
- res , err = client .HTTL (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
1227
- Expect (err ).NotTo (HaveOccurred ())
1228
- Expect (res ).To (Equal ([]int64 {10 , - 1 , - 2 }))
1229
- })
1230
-
1231
- It ("should HPTTL" , func () {
1232
- _ , err := client .HPTTL (ctx , "no_such_key" , "field1" , "field2" , "field3" ).Result ()
1233
- Expect (err ).To (HaveOccurred ())
1234
- for i := 0 ; i < 100 ; i ++ {
1235
- sadd := client .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
1236
- Expect (sadd .Err ()).NotTo (HaveOccurred ())
1237
- }
1238
-
1239
- res , err := client .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
1240
- Expect (err ).NotTo (HaveOccurred ())
1241
- Expect (res ).To (Equal ([]int64 {1 , - 2 }))
1242
-
1243
- res , err = client .HPTTL (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
1244
- Expect (err ).NotTo (HaveOccurred ())
1245
- Expect (res [0 ]).To (BeNumerically ("~" , 10 * time .Second .Milliseconds (), 1 ))
1246
- })
1247
-
1248
- It ("should HSetF and HGetF" , func () {
1249
- sadd := client .HSetF (ctx , "myhash" , redis.HSetFArgs {}, "field1" , "Hello" , "field2" , "World" )
1250
- Expect (sadd .Err ()).NotTo (HaveOccurred ())
1251
- Expect (sadd .Val ()).To (Equal ([]string {"1" , "1" }))
1252
-
1253
- for i := 0 ; i < 100 ; i ++ {
1254
- sadd := client .HSetF (ctx , "myhash" , redis.HSetFArgs {}, fmt .Sprintf ("key%d" , i ), "Hello" )
1255
- Expect (sadd .Err ()).NotTo (HaveOccurred ())
1256
- Expect (sadd .Val ()).To (Equal ([]string {"1" }))
1257
- }
1258
-
1259
- res , err := client .HSetF (ctx , "myhash" , redis.HSetFArgs {GETOLD : true , EX : 10 }, "field1" , "Hello" , "field2" , "World" , "field3" , "foo" ).Result ()
1260
- Expect (err ).NotTo (HaveOccurred ())
1261
- Expect (res ).To (BeEquivalentTo ([]string {"Hello" , "World" , "" }))
1262
-
1263
- res , err = client .HSetF (ctx , "myhash" , redis.HSetFArgs {DOF : true }, "field1" , "Hello" , "field2" , "World" , "field4" , "bar" ).Result ()
1264
- Expect (err ).NotTo (HaveOccurred ())
1265
- Expect (res ).To (BeEquivalentTo ([]string {"0" , "0" , "1" }))
1266
-
1267
- res , err = client .HGetF (ctx , "myhash" , redis.HGetFArgs {Persist : true }, "field1" , "field2" , "field3" ).Result ()
1268
- Expect (err ).NotTo (HaveOccurred ())
1269
- Expect (res ).To (BeEquivalentTo ([]string {"Hello" , "World" , "foo" }))
1270
-
1271
- })
1272
-
1273
1107
It ("should ZScan" , func () {
1274
1108
for i := 0 ; i < 1000 ; i ++ {
1275
1109
err := client .ZAdd (ctx , "myset" , redis.Z {
@@ -2596,6 +2430,157 @@ var _ = Describe("Commands", func() {
2596
2430
Equal ([]redis.KeyValue {{Key : "key2" , Value : "hello2" }}),
2597
2431
))
2598
2432
})
2433
+
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 ())
2439
+ for i := 0 ; i < 100 ; i ++ {
2440
+ sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2441
+ Expect (sadd .Err ()).NotTo (HaveOccurred ())
2442
+ }
2443
+
2444
+ res , err = client1 .HExpire (ctx , "myhash" , 10 , "key1" , "key2" , "key200" ).Result ()
2445
+ Expect (err ).NotTo (HaveOccurred ())
2446
+ Expect (res ).To (Equal ([]int64 {1 , 1 , - 2 }))
2447
+ })
2448
+
2449
+ 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 ())
2453
+ for i := 0 ; i < 100 ; i ++ {
2454
+ sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2455
+ Expect (sadd .Err ()).NotTo (HaveOccurred ())
2456
+ }
2457
+
2458
+ res , err := client1 .HPExpire (ctx , "myhash" , 10 , "key1" , "key2" , "key200" ).Result ()
2459
+ Expect (err ).NotTo (HaveOccurred ())
2460
+ Expect (res ).To (Equal ([]int64 {1 , 1 , - 2 }))
2461
+ })
2462
+
2463
+ 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 ())
2467
+ for i := 0 ; i < 100 ; i ++ {
2468
+ sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2469
+ Expect (sadd .Err ()).NotTo (HaveOccurred ())
2470
+ }
2471
+
2472
+ res , err := client1 .HExpireAt (ctx , "myhash" , time .Now ().Add (10 * time .Second ), "key1" , "key2" , "key200" ).Result ()
2473
+ Expect (err ).NotTo (HaveOccurred ())
2474
+ Expect (res ).To (Equal ([]int64 {1 , 1 , - 2 }))
2475
+ })
2476
+
2477
+ 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 ())
2481
+ for i := 0 ; i < 100 ; i ++ {
2482
+ sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2483
+ Expect (sadd .Err ()).NotTo (HaveOccurred ())
2484
+ }
2485
+
2486
+ res , err := client1 .HPExpireAt (ctx , "myhash" , time .Now ().Add (10 * time .Second ), "key1" , "key2" , "key200" ).Result ()
2487
+ Expect (err ).NotTo (HaveOccurred ())
2488
+ Expect (res ).To (Equal ([]int64 {1 , 1 , - 2 }))
2489
+ })
2490
+
2491
+ 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 ())
2495
+ for i := 0 ; i < 100 ; i ++ {
2496
+ sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2497
+ Expect (sadd .Err ()).NotTo (HaveOccurred ())
2498
+ }
2499
+
2500
+ res , err := client1 .HPersist (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2501
+ Expect (err ).NotTo (HaveOccurred ())
2502
+ Expect (res ).To (Equal ([]int64 {- 1 , - 1 , - 2 }))
2503
+
2504
+ res , err = client1 .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
2505
+ Expect (err ).NotTo (HaveOccurred ())
2506
+ Expect (res ).To (Equal ([]int64 {1 , - 2 }))
2507
+
2508
+ res , err = client1 .HPersist (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2509
+ Expect (err ).NotTo (HaveOccurred ())
2510
+ Expect (res ).To (Equal ([]int64 {1 , - 1 , - 2 }))
2511
+ })
2512
+
2513
+ 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 ())
2517
+ for i := 0 ; i < 100 ; i ++ {
2518
+ sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2519
+ Expect (sadd .Err ()).NotTo (HaveOccurred ())
2520
+ }
2521
+
2522
+ res , err := client1 .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
2523
+ Expect (err ).NotTo (HaveOccurred ())
2524
+ Expect (res ).To (Equal ([]int64 {1 , - 2 }))
2525
+
2526
+ res , err = client1 .HExpireTime (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2527
+ Expect (err ).NotTo (HaveOccurred ())
2528
+ Expect (res [0 ]).To (BeNumerically ("~" , time .Now ().Add (10 * time .Second ).Unix (), 1 ))
2529
+ })
2530
+
2531
+ 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 ())
2535
+ for i := 0 ; i < 100 ; i ++ {
2536
+ sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2537
+ Expect (sadd .Err ()).NotTo (HaveOccurred ())
2538
+ }
2539
+
2540
+ res , err := client1 .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
2541
+ Expect (err ).NotTo (HaveOccurred ())
2542
+ Expect (res ).To (Equal ([]int64 {1 , - 2 }))
2543
+
2544
+ res , err = client1 .HPExpireTime (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2545
+ Expect (err ).NotTo (HaveOccurred ())
2546
+ Expect (res ).To (BeEquivalentTo ([]int64 {time .Now ().Add (10 * time .Second ).UnixMilli (), - 1 , - 2 }))
2547
+ })
2548
+
2549
+ 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 ())
2553
+ for i := 0 ; i < 100 ; i ++ {
2554
+ sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2555
+ Expect (sadd .Err ()).NotTo (HaveOccurred ())
2556
+ }
2557
+
2558
+ res , err := client1 .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
2559
+ Expect (err ).NotTo (HaveOccurred ())
2560
+ Expect (res ).To (Equal ([]int64 {1 , - 2 }))
2561
+
2562
+ res , err = client1 .HTTL (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2563
+ Expect (err ).NotTo (HaveOccurred ())
2564
+ Expect (res ).To (Equal ([]int64 {10 , - 1 , - 2 }))
2565
+ })
2566
+
2567
+ 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 ())
2571
+ for i := 0 ; i < 100 ; i ++ {
2572
+ sadd := client1 .HSet (ctx , "myhash" , fmt .Sprintf ("key%d" , i ), "hello" )
2573
+ Expect (sadd .Err ()).NotTo (HaveOccurred ())
2574
+ }
2575
+
2576
+ res , err := client1 .HExpire (ctx , "myhash" , 10 , "key1" , "key200" ).Result ()
2577
+ Expect (err ).NotTo (HaveOccurred ())
2578
+ Expect (res ).To (Equal ([]int64 {1 , - 2 }))
2579
+
2580
+ res , err = client1 .HPTTL (ctx , "myhash" , "key1" , "key2" , "key200" ).Result ()
2581
+ Expect (err ).NotTo (HaveOccurred ())
2582
+ Expect (res [0 ]).To (BeNumerically ("~" , 10 * time .Second .Milliseconds (), 1 ))
2583
+ })
2599
2584
})
2600
2585
2601
2586
Describe ("hyperloglog" , func () {
0 commit comments