Skip to content

Commit 2c446fa

Browse files
committed
fix types
1 parent 26c1370 commit 2c446fa

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

hash_commands.go

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ type HashCmdable interface {
1010
HExists(ctx context.Context, key, field string) *BoolCmd
1111
HGet(ctx context.Context, key, field string) *StringCmd
1212
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
1616
HIncrBy(ctx context.Context, key, field string, incr int64) *IntCmd
1717
HIncrByFloat(ctx context.Context, key, field string, incr float64) *FloatCmd
1818
HKeys(ctx context.Context, key string) *StringSliceCmd
@@ -460,28 +460,27 @@ func (c cmdable) HPTTL(ctx context.Context, key string, fields ...string) *IntSl
460460
return cmd
461461
}
462462

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 {
465464
args := []interface{}{"HGETDEL", key, "FIELDS", len(fields)}
466465
for _, field := range fields {
467466
args = append(args, field)
468467
}
469-
cmd := NewIntSliceCmd(ctx, args...)
468+
cmd := NewStringSliceCmd(ctx, args...)
470469
_ = c(ctx, cmd)
471470
return cmd
472471
}
473472

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 {
475474
args := []interface{}{"HGETEX", key, "FIELDS", len(fields)}
476475
for _, field := range fields {
477476
args = append(args, field)
478477
}
479-
cmd := NewIntSliceCmd(ctx, args...)
478+
cmd := NewStringSliceCmd(ctx, args...)
480479
_ = c(ctx, cmd)
481480
return cmd
482481
}
483482

484-
// ExpirationType represents an expiration option for the hash commands.
483+
// ExpirationType represents an expiration option for the HGETEX command.
485484
type HGetEXExpirationType string
486485

487486
const (
@@ -492,10 +491,9 @@ const (
492491
HGetEXExpirationPERSIST HGetEXExpirationType = "PERSIST"
493492
)
494493

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 {
496495
args := []interface{}{"HGETEX", key}
497496

498-
// Append expiration option and its value if necessary.
499497
args = append(args, string(expirationType))
500498
if expirationType != HGetEXExpirationPERSIST {
501499
args = append(args, expirationVal)
@@ -506,7 +504,7 @@ func (c cmdable) HGetEXWithArgs(ctx context.Context, key string, expirationType
506504
args = append(args, field)
507505
}
508506

509-
cmd := NewIntSliceCmd(ctx, args...)
507+
cmd := NewStringSliceCmd(ctx, args...)
510508
_ = c(ctx, cmd)
511509
return cmd
512510
}
@@ -535,7 +533,7 @@ type HSetXOptions struct {
535533
}
536534

537535
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}
539537
for _, field := range fieldsAndValues {
540538
args = append(args, field)
541539
}
@@ -546,7 +544,6 @@ func (c cmdable) HSetEX(ctx context.Context, key string, fieldsAndValues ...stri
546544
}
547545

548546
func (c cmdable) HSetEXWithArgs(ctx context.Context, key string, options *HSetXOptions, fieldsAndValues ...string) *IntCmd {
549-
// Start with the command name and key.
550547
args := []interface{}{"HSETEX", key}
551548
if options.Condition != "" {
552549
args = append(args, string(options.Condition))
@@ -557,12 +554,11 @@ func (c cmdable) HSetEXWithArgs(ctx context.Context, key string, options *HSetXO
557554
args = append(args, options.ExpirationVal)
558555
}
559556
}
560-
args = append(args, "FIELDS", len(fieldsAndValues))
557+
args = append(args, "FIELDS", len(fieldsAndValues)/2)
561558
for _, field := range fieldsAndValues {
562559
args = append(args, field)
563560
}
564561

565-
// Create and execute the command.
566562
cmd := NewIntCmd(ctx, args...)
567563
_ = c(ctx, cmd)
568564
return cmd

0 commit comments

Comments
 (0)