@@ -10,9 +10,9 @@ type HashCmdable interface {
10
10
HExists (ctx context.Context , key , field string ) * BoolCmd
11
11
HGet (ctx context.Context , key , field string ) * StringCmd
12
12
HGetAll (ctx context.Context , key string ) * MapStringStringCmd
13
- HGetDel (ctx context.Context , key string , fields ... string ) * IntSliceCmd
14
- HGetEX (ctx context.Context , key string , fields ... string ) * IntSliceCmd
15
- HGetEXWithArgs (ctx context.Context , key string , expirationType HGetEXExpirationType , expirationVal int64 , fields ... string ) * IntSliceCmd
13
+ HGetDel (ctx context.Context , key string , fields ... string ) * StringSliceCmd
14
+ HGetEX (ctx context.Context , key string , fields ... string ) * StringSliceCmd
15
+ HGetEXWithArgs (ctx context.Context , key string , expirationType HGetEXExpirationType , expirationVal int64 , fields ... string ) * StringSliceCmd
16
16
HIncrBy (ctx context.Context , key , field string , incr int64 ) * IntCmd
17
17
HIncrByFloat (ctx context.Context , key , field string , incr float64 ) * FloatCmd
18
18
HKeys (ctx context.Context , key string ) * StringSliceCmd
@@ -460,28 +460,27 @@ func (c cmdable) HPTTL(ctx context.Context, key string, fields ...string) *IntSl
460
460
return cmd
461
461
}
462
462
463
- // TODO check return type
464
- func (c cmdable ) HGetDel (ctx context.Context , key string , fields ... string ) * IntSliceCmd {
463
+ func (c cmdable ) HGetDel (ctx context.Context , key string , fields ... string ) * StringSliceCmd {
465
464
args := []interface {}{"HGETDEL" , key , "FIELDS" , len (fields )}
466
465
for _ , field := range fields {
467
466
args = append (args , field )
468
467
}
469
- cmd := NewIntSliceCmd (ctx , args ... )
468
+ cmd := NewStringSliceCmd (ctx , args ... )
470
469
_ = c (ctx , cmd )
471
470
return cmd
472
471
}
473
472
474
- func (c cmdable ) HGetEX (ctx context.Context , key string , fields ... string ) * IntSliceCmd {
473
+ func (c cmdable ) HGetEX (ctx context.Context , key string , fields ... string ) * StringSliceCmd {
475
474
args := []interface {}{"HGETEX" , key , "FIELDS" , len (fields )}
476
475
for _ , field := range fields {
477
476
args = append (args , field )
478
477
}
479
- cmd := NewIntSliceCmd (ctx , args ... )
478
+ cmd := NewStringSliceCmd (ctx , args ... )
480
479
_ = c (ctx , cmd )
481
480
return cmd
482
481
}
483
482
484
- // ExpirationType represents an expiration option for the hash commands .
483
+ // ExpirationType represents an expiration option for the HGETEX command .
485
484
type HGetEXExpirationType string
486
485
487
486
const (
@@ -492,10 +491,9 @@ const (
492
491
HGetEXExpirationPERSIST HGetEXExpirationType = "PERSIST"
493
492
)
494
493
495
- func (c cmdable ) HGetEXWithArgs (ctx context.Context , key string , expirationType HGetEXExpirationType , expirationVal int64 , fields ... string ) * IntSliceCmd {
494
+ func (c cmdable ) HGetEXWithArgs (ctx context.Context , key string , expirationType HGetEXExpirationType , expirationVal int64 , fields ... string ) * StringSliceCmd {
496
495
args := []interface {}{"HGETEX" , key }
497
496
498
- // Append expiration option and its value if necessary.
499
497
args = append (args , string (expirationType ))
500
498
if expirationType != HGetEXExpirationPERSIST {
501
499
args = append (args , expirationVal )
@@ -506,7 +504,7 @@ func (c cmdable) HGetEXWithArgs(ctx context.Context, key string, expirationType
506
504
args = append (args , field )
507
505
}
508
506
509
- cmd := NewIntSliceCmd (ctx , args ... )
507
+ cmd := NewStringSliceCmd (ctx , args ... )
510
508
_ = c (ctx , cmd )
511
509
return cmd
512
510
}
@@ -535,7 +533,7 @@ type HSetXOptions struct {
535
533
}
536
534
537
535
func (c cmdable ) HSetEX (ctx context.Context , key string , fieldsAndValues ... string ) * IntCmd {
538
- args := []interface {}{"HSETEX" , key , "FIELDS" , len (fieldsAndValues )}
536
+ args := []interface {}{"HSETEX" , key , "FIELDS" , len (fieldsAndValues ) / 2 }
539
537
for _ , field := range fieldsAndValues {
540
538
args = append (args , field )
541
539
}
@@ -546,7 +544,6 @@ func (c cmdable) HSetEX(ctx context.Context, key string, fieldsAndValues ...stri
546
544
}
547
545
548
546
func (c cmdable ) HSetEXWithArgs (ctx context.Context , key string , options * HSetXOptions , fieldsAndValues ... string ) * IntCmd {
549
- // Start with the command name and key.
550
547
args := []interface {}{"HSETEX" , key }
551
548
if options .Condition != "" {
552
549
args = append (args , string (options .Condition ))
@@ -557,12 +554,11 @@ func (c cmdable) HSetEXWithArgs(ctx context.Context, key string, options *HSetXO
557
554
args = append (args , options .ExpirationVal )
558
555
}
559
556
}
560
- args = append (args , "FIELDS" , len (fieldsAndValues ))
557
+ args = append (args , "FIELDS" , len (fieldsAndValues )/ 2 )
561
558
for _ , field := range fieldsAndValues {
562
559
args = append (args , field )
563
560
}
564
561
565
- // Create and execute the command.
566
562
cmd := NewIntCmd (ctx , args ... )
567
563
_ = c (ctx , cmd )
568
564
return cmd
0 commit comments