@@ -46,9 +46,18 @@ type Cmder interface {
4646}
4747
4848type baseCmd [T any ] struct {
49- err error
50- val T
51- rawVal any
49+ err error
50+ val T
51+ rawVal any
52+ isCacheHit bool
53+ }
54+
55+ func (cmd * baseCmd [T ]) setIsCacheHit (val bool ) {
56+ cmd .isCacheHit = val
57+ }
58+
59+ func (cmd * baseCmd [T ]) IsCacheHit () bool {
60+ return cmd .isCacheHit
5261}
5362
5463func (cmd * baseCmd [T ]) SetVal (val T ) {
@@ -94,6 +103,7 @@ func (cmd *Cmd) from(res rueidis.RedisResult) {
94103 return
95104 }
96105 cmd .SetVal (val )
106+ cmd .setIsCacheHit (res .IsCacheHit ())
97107}
98108
99109func newCmd (res rueidis.RedisResult ) * Cmd {
@@ -355,6 +365,7 @@ func (cmd *StringCmd) from(res rueidis.RedisResult) {
355365 val , err := res .ToString ()
356366 cmd .SetErr (err )
357367 cmd .SetVal (val )
368+ cmd .setIsCacheHit (res .IsCacheHit ())
358369}
359370
360371func newStringCmd (res rueidis.RedisResult ) * StringCmd {
@@ -433,6 +444,7 @@ func (cmd *BoolCmd) from(res rueidis.RedisResult) {
433444 }
434445 cmd .SetVal (val )
435446 cmd .SetErr (err )
447+ cmd .setIsCacheHit (res .IsCacheHit ())
436448}
437449
438450func newBoolCmd (res rueidis.RedisResult ) * BoolCmd {
@@ -474,6 +486,7 @@ func (cmd *DurationCmd) from(res rueidis.RedisResult) {
474486 return
475487 }
476488 cmd .SetVal (time .Duration (val ))
489+ cmd .setIsCacheHit (res .IsCacheHit ())
477490}
478491
479492func newDurationCmd (res rueidis.RedisResult , precision time.Duration ) * DurationCmd {
@@ -529,6 +542,7 @@ func (cmd *SliceCmd) from(res rueidis.RedisResult) {
529542 }
530543 }
531544 cmd .SetVal (vals )
545+ cmd .setIsCacheHit (res .IsCacheHit ())
532546}
533547
534548// newSliceCmd returns SliceCmd according to input arguments, if the caller is JSONObjKeys,
@@ -557,6 +571,7 @@ func (cmd *StringSliceCmd) from(res rueidis.RedisResult) {
557571 val , err := res .AsStrSlice ()
558572 cmd .SetVal (val )
559573 cmd .SetErr (err )
574+ cmd .setIsCacheHit (res .IsCacheHit ())
560575}
561576
562577func newStringSliceCmd (res rueidis.RedisResult ) * StringSliceCmd {
@@ -566,13 +581,14 @@ func newStringSliceCmd(res rueidis.RedisResult) *StringSliceCmd {
566581}
567582
568583type IntSliceCmd struct {
569- err error
570- val []int64
584+ err error
585+ val []int64
586+ isCacheHit bool
571587}
572588
573589func (cmd * IntSliceCmd ) from (res rueidis.RedisResult ) {
574590 cmd .val , cmd .err = res .AsIntSlice ()
575-
591+ cmd . setIsCacheHit ( res . IsCacheHit ())
576592}
577593
578594func newIntSliceCmd (res rueidis.RedisResult ) * IntSliceCmd {
@@ -581,6 +597,10 @@ func newIntSliceCmd(res rueidis.RedisResult) *IntSliceCmd {
581597 return cmd
582598}
583599
600+ func (cmd * IntSliceCmd ) setIsCacheHit (isCacheHit bool ) {
601+ cmd .isCacheHit = isCacheHit
602+ }
603+
584604func (cmd * IntSliceCmd ) SetVal (val []int64 ) {
585605 cmd .val = val
586606}
@@ -601,6 +621,10 @@ func (cmd *IntSliceCmd) Result() ([]int64, error) {
601621 return cmd .val , cmd .err
602622}
603623
624+ func (cmd * IntSliceCmd ) IsCacheHit () bool {
625+ return cmd .isCacheHit
626+ }
627+
604628type BoolSliceCmd struct {
605629 baseCmd [[]bool ]
606630}
@@ -616,6 +640,7 @@ func (cmd *BoolSliceCmd) from(res rueidis.RedisResult) {
616640 val = append (val , i == 1 )
617641 }
618642 cmd .SetVal (val )
643+ cmd .setIsCacheHit (res .IsCacheHit ())
619644}
620645
621646func newBoolSliceCmd (res rueidis.RedisResult ) * BoolSliceCmd {
@@ -632,6 +657,7 @@ func (cmd *FloatSliceCmd) from(res rueidis.RedisResult) {
632657 val , err := res .AsFloatSlice ()
633658 cmd .SetErr (err )
634659 cmd .SetVal (val )
660+ cmd .setIsCacheHit (res .IsCacheHit ())
635661}
636662
637663func newFloatSliceCmd (res rueidis.RedisResult ) * FloatSliceCmd {
@@ -653,6 +679,7 @@ func (cmd *ZSliceCmd) from(res rueidis.RedisResult) {
653679 return
654680 }
655681 cmd .SetVal ([]Z {{Member : s .Member , Score : s .Score }})
682+ cmd .setIsCacheHit (res .IsCacheHit ())
656683 } else {
657684 scores , err := res .AsZScores ()
658685 if err != nil {
@@ -664,6 +691,7 @@ func (cmd *ZSliceCmd) from(res rueidis.RedisResult) {
664691 val = append (val , Z {Member : s .Member , Score : s .Score })
665692 }
666693 cmd .SetVal (val )
694+ cmd .setIsCacheHit (res .IsCacheHit ())
667695 }
668696}
669697
@@ -687,6 +715,7 @@ func (cmd *FloatCmd) from(res rueidis.RedisResult) {
687715 val , err := res .AsFloat64 ()
688716 cmd .SetErr (err )
689717 cmd .SetVal (val )
718+ cmd .setIsCacheHit (res .IsCacheHit ())
690719}
691720
692721func newFloatCmd (res rueidis.RedisResult ) * FloatCmd {
@@ -881,6 +910,7 @@ func (cmd *StringStringMapCmd) from(res rueidis.RedisResult) {
881910 val , err := res .AsStrMap ()
882911 cmd .SetErr (err )
883912 cmd .SetVal (val )
913+ cmd .setIsCacheHit (res .IsCacheHit ())
884914}
885915
886916func newStringStringMapCmd (res rueidis.RedisResult ) * StringStringMapCmd {
@@ -1753,6 +1783,7 @@ func (cmd *RankWithScoreCmd) from(res rueidis.RedisResult) {
17531783 cmd .val .Score , _ = vs [1 ].AsFloat64 ()
17541784 }
17551785 }
1786+ cmd .setIsCacheHit (res .IsCacheHit ())
17561787}
17571788
17581789func newRankWithScoreCmd (res rueidis.RedisResult ) * RankWithScoreCmd {
@@ -2027,6 +2058,7 @@ func (cmd *GeoPosCmd) from(res rueidis.RedisResult) {
20272058 })
20282059 }
20292060 cmd .SetVal (val )
2061+ cmd .setIsCacheHit (res .IsCacheHit ())
20302062}
20312063
20322064func newGeoPosCmd (res rueidis.RedisResult ) * GeoPosCmd {
@@ -2041,6 +2073,7 @@ type GeoLocationCmd struct {
20412073
20422074func (cmd * GeoLocationCmd ) from (res rueidis.RedisResult ) {
20432075 cmd .val , cmd .err = res .AsGeosearch ()
2076+ cmd .setIsCacheHit (res .IsCacheHit ())
20442077}
20452078
20462079func newGeoLocationCmd (res rueidis.RedisResult ) * GeoLocationCmd {
@@ -2674,6 +2707,7 @@ func (cmd *BFInfoCmd) from(res rueidis.RedisResult) {
26742707 return
26752708 }
26762709 cmd .SetVal (info )
2710+ cmd .setIsCacheHit (res .IsCacheHit ())
26772711}
26782712
26792713func newBFInfoCmd (res rueidis.RedisResult ) * BFInfoCmd {
@@ -2764,6 +2798,7 @@ func (cmd *CFInfoCmd) from(res rueidis.RedisResult) {
27642798 return
27652799 }
27662800 cmd .SetVal (info )
2801+ cmd .setIsCacheHit (res .IsCacheHit ())
27672802}
27682803
27692804func newCFInfoCmd (res rueidis.RedisResult ) * CFInfoCmd {
@@ -2800,6 +2835,7 @@ func (cmd *CMSInfoCmd) from(res rueidis.RedisResult) {
28002835 return
28012836 }
28022837 cmd .SetVal (info )
2838+ cmd .setIsCacheHit (res .IsCacheHit ())
28032839}
28042840
28052841func newCMSInfoCmd (res rueidis.RedisResult ) * CMSInfoCmd {
@@ -2855,6 +2891,7 @@ func (cmd *TopKInfoCmd) from(res rueidis.RedisResult) {
28552891 return
28562892 }
28572893 cmd .SetVal (info )
2894+ cmd .setIsCacheHit (res .IsCacheHit ())
28582895}
28592896
28602897func newTopKInfoCmd (res rueidis.RedisResult ) * TopKInfoCmd {
@@ -2874,6 +2911,7 @@ func (cmd *MapStringIntCmd) from(res rueidis.RedisResult) {
28742911 return
28752912 }
28762913 cmd .SetVal (m )
2914+ cmd .setIsCacheHit (res .IsCacheHit ())
28772915}
28782916
28792917func newMapStringIntCmd (res rueidis.RedisResult ) * MapStringIntCmd {
@@ -3281,6 +3319,7 @@ func (cmd *JSONCmd) from(res rueidis.RedisResult) {
32813319 cmd .SetErr (err )
32823320 return
32833321 }
3322+ cmd .setIsCacheHit (res .IsCacheHit ())
32843323 switch {
32853324 // JSON.GET
32863325 case msg .IsString ():
@@ -3362,6 +3401,7 @@ func (cmd *IntPointerSliceCmd) from(res rueidis.RedisResult) {
33623401 intPtrSlice [i ] = & length
33633402 }
33643403 cmd .SetVal (intPtrSlice )
3404+ cmd .setIsCacheHit (res .IsCacheHit ())
33653405}
33663406
33673407// newIntPointerSliceCmd initialises an IntPointerSliceCmd
@@ -3394,6 +3434,7 @@ func (cmd *JSONSliceCmd) from(res rueidis.RedisResult) {
33943434 anySlice [i ] = anyE
33953435 }
33963436 cmd .SetVal (anySlice )
3437+ cmd .setIsCacheHit (res .IsCacheHit ())
33973438}
33983439
33993440func newJSONSliceCmd (res rueidis.RedisResult ) * JSONSliceCmd {
0 commit comments