Skip to content

Commit 16536fe

Browse files
John LuoBrennanConroyaleprisecaru
authored
Replaced eval script with native command to read from redis. Native commands have better performance compared to EVAL/EVALSHA scripts (#3680) (#28259)
Co-authored-by: Alexandra Elena Prisecaru <[email protected]> Co-authored-by: Brennan <[email protected]> Co-authored-by: Alexandra Elena Prisecaru <[email protected]>
1 parent 9b1ba0f commit 16536fe

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

src/Caching/StackExchangeRedis/src/RedisExtensions.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,19 @@ namespace Microsoft.Extensions.Caching.StackExchangeRedis
99
{
1010
internal static class RedisExtensions
1111
{
12-
private const string HmGetScript = (@"return redis.call('HMGET', KEYS[1], unpack(ARGV))");
13-
1412
internal static RedisValue[] HashMemberGet(this IDatabase cache, string key, params string[] members)
1513
{
16-
var result = cache.ScriptEvaluate(
17-
HmGetScript,
18-
new RedisKey[] { key },
19-
GetRedisMembers(members));
20-
2114
// TODO: Error checking?
22-
return (RedisValue[])result;
15+
return cache.HashGet(key, GetRedisMembers(members));
2316
}
2417

2518
internal static async Task<RedisValue[]> HashMemberGetAsync(
2619
this IDatabase cache,
2720
string key,
2821
params string[] members)
2922
{
30-
var result = await cache.ScriptEvaluateAsync(
31-
HmGetScript,
32-
new RedisKey[] { key },
33-
GetRedisMembers(members)).ConfigureAwait(false);
34-
3523
// TODO: Error checking?
36-
return (RedisValue[])result;
24+
return await cache.HashGetAsync(key, GetRedisMembers(members)).ConfigureAwait(false);
3725
}
3826

3927
private static RedisValue[] GetRedisMembers(params string[] members)

0 commit comments

Comments
 (0)