Browse Source

Update AbpRedisCache

pull/13711/head
liangshiwei 4 years ago
parent
commit
56b9d9b10f
  1. 10
      framework/src/Volo.Abp.Caching.StackExchangeRedis/Volo/Abp/Caching/StackExchangeRedis/AbpRedisCache.cs

10
framework/src/Volo.Abp.Caching.StackExchangeRedis/Volo/Abp/Caching/StackExchangeRedis/AbpRedisCache.cs

@ -15,7 +15,6 @@ namespace Volo.Abp.Caching.StackExchangeRedis;
[DisableConventionalRegistration] [DisableConventionalRegistration]
public class AbpRedisCache : RedisCache, ICacheSupportsMultipleItems public class AbpRedisCache : RedisCache, ICacheSupportsMultipleItems
{ {
protected static string SetScript;
protected static readonly string AbsoluteExpirationKey; protected static readonly string AbsoluteExpirationKey;
protected static readonly string SlidingExpirationKey; protected static readonly string SlidingExpirationKey;
protected static readonly string DataKey; protected static readonly string DataKey;
@ -71,7 +70,6 @@ public class AbpRedisCache : RedisCache, ICacheSupportsMultipleItems
: base(optionsAccessor) : base(optionsAccessor)
{ {
Instance = optionsAccessor.Value.InstanceName ?? string.Empty; Instance = optionsAccessor.Value.InstanceName ?? string.Empty;
Connect();
} }
protected virtual void Connect() protected virtual void Connect()
@ -82,7 +80,6 @@ public class AbpRedisCache : RedisCache, ICacheSupportsMultipleItems
} }
ConnectMethod.Invoke(this, Array.Empty<object>()); ConnectMethod.Invoke(this, Array.Empty<object>());
SetSetScript();
} }
protected virtual async Task ConnectAsync(CancellationToken token = default) protected virtual async Task ConnectAsync(CancellationToken token = default)
@ -93,7 +90,6 @@ public class AbpRedisCache : RedisCache, ICacheSupportsMultipleItems
} }
await (Task)ConnectAsyncMethod.Invoke(this, new object[] { token }); await (Task)ConnectAsyncMethod.Invoke(this, new object[] { token });
SetSetScript();
} }
public byte[][] GetMany( public byte[][] GetMany(
@ -286,7 +282,7 @@ public class AbpRedisCache : RedisCache, ICacheSupportsMultipleItems
for (var i = 0; i < itemArray.Length; i++) for (var i = 0; i < itemArray.Length; i++)
{ {
tasks[i] = RedisDatabase.ScriptEvaluateAsync(SetScript, new RedisKey[] { Instance + itemArray[i].Key }, tasks[i] = RedisDatabase.ScriptEvaluateAsync(GetSetScript(), new RedisKey[] { Instance + itemArray[i].Key },
new RedisValue[] new RedisValue[]
{ {
absoluteExpiration?.Ticks ?? NotPresent, absoluteExpiration?.Ticks ?? NotPresent,
@ -337,8 +333,8 @@ public class AbpRedisCache : RedisCache, ICacheSupportsMultipleItems
return _redisDatabase; return _redisDatabase;
} }
private void SetSetScript() private string GetSetScript()
{ {
SetScript = SetScriptField?.GetValue(this).ToString(); return SetScriptField?.GetValue(this).ToString();
} }
} }

Loading…
Cancel
Save