Skip to content

Commit dcfe108

Browse files
committed
update RedisIndex.Lookup
Signed-off-by: sagiahrac <[email protected]> Signed-off-by: Sage Ahrac <[email protected]>
1 parent 8cf325e commit dcfe108

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

pkg/kvcache/kvblock/redis.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,13 @@ var _ Index = &RedisIndex{}
8080
// If the podIdentifierSet is empty, all pods are returned.
8181
//
8282
// It returns:
83-
// 1. A slice of the hit keys.
84-
// 2. A map where the keys are those in (1) and the values are pod-identifiers.
85-
// 3. An error if any occurred during the operation.
83+
// 1. A map where the keys are those in (1) and the values are pod-identifiers.
84+
// 2. An error if any occurred during the operation.
8685
func (r *RedisIndex) Lookup(ctx context.Context, keys []Key,
8786
podIdentifierSet sets.Set[string],
88-
) ([]Key, map[Key][]string, error) {
87+
) (map[Key][]string, error) {
8988
if len(keys) == 0 {
90-
return nil, nil, nil
89+
return nil, nil
9190
}
9291

9392
logger := klog.FromContext(ctx).WithName("kvblock.RedisIndex.Lookup")
@@ -105,11 +104,10 @@ func (r *RedisIndex) Lookup(ctx context.Context, keys []Key,
105104

106105
_, execErr := pipe.Exec(ctx)
107106
if execErr != nil {
108-
return nil, nil, fmt.Errorf("redis pipeline execution failed: %w", execErr)
107+
return nil, fmt.Errorf("redis pipeline execution failed: %w", execErr)
109108
}
110109

111110
filterPods := len(podIdentifierSet) > 0 // predicate for filtering
112-
highestHitIdx := 0
113111

114112
for idx, cmd := range results {
115113
key := keys[idx]
@@ -121,7 +119,7 @@ func (r *RedisIndex) Lookup(ctx context.Context, keys []Key,
121119
logger.Error(cmdErr, "failed to get pods for key", "key", key)
122120
}
123121

124-
return keys[:idx], podsPerKey, nil // early stop since prefix-chain breaks here
122+
return podsPerKey, nil // early stop since prefix-chain breaks here
125123
}
126124

127125
var filteredPods []string
@@ -134,14 +132,13 @@ func (r *RedisIndex) Lookup(ctx context.Context, keys []Key,
134132

135133
if len(filteredPods) == 0 {
136134
logger.Info("no pods found for key, cutting search", "key", key)
137-
return keys[:idx], podsPerKey, nil // early stop since prefix-chain breaks here
135+
return podsPerKey, nil // early stop since prefix-chain breaks here
138136
}
139137

140-
highestHitIdx = idx
141138
podsPerKey[key] = filteredPods
142139
}
143140

144-
return keys[:highestHitIdx+1], podsPerKey, nil
141+
return podsPerKey, nil
145142
}
146143

147144
// Add adds a set of keys and their associated pod entries to the index backend.

0 commit comments

Comments
 (0)