Skip to content

Commit

Permalink
storage: avoid MGET call when no keys are specified (TykTechnologies#…
Browse files Browse the repository at this point in the history
…2156)

Fixes TykTechnologies#2155 

`GetKeysAndValuesWithFilter` lists keys and runs `MGET`(https://redis.io/commands/mget) using these keys. This patch avoids the `MGET` call when the list is empty.

This method is only called by the `oauth_manager.go` code.
  • Loading branch information
matiasinsaurralde authored and buger committed Mar 8, 2019
1 parent 14ffe74 commit 51f00fd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions storage/redis_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ func (r *RedisCluster) GetKeysAndValuesWithFilter(filter string) map[string]stri
}

keys, _ := redis.Strings(sessionsInterface, err)
if len(keys) == 0 {
return nil
}
valueObj, err := r.singleton().Do("MGET", sessionsInterface.([]interface{})...)
values, err := redis.Strings(valueObj, err)
if err != nil {
Expand Down

0 comments on commit 51f00fd

Please sign in to comment.