Skip to content

Commit

Permalink
允许重写AcquireLock,解决FullRedis中AcquireLock不支持前缀的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
andywu188 committed May 8, 2024
1 parent 66f99ab commit 52c2dc9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions NewLife.Core/Caching/Cache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public virtual Double Decrement(String key, Double value)
/// <param name="key">要锁定的key</param>
/// <param name="msTimeout">锁等待时间,单位毫秒</param>
/// <returns></returns>
public IDisposable? AcquireLock(String key, Int32 msTimeout)
public virtual IDisposable? AcquireLock(String key, Int32 msTimeout)
{
var rlock = new CacheLock(this, key);
if (!rlock.Acquire(msTimeout, msTimeout)) throw new InvalidOperationException($"Lock [{key}] failed! msTimeout={msTimeout}");
Expand All @@ -295,7 +295,7 @@ public virtual Double Decrement(String key, Double value)
/// <param name="msExpire">锁过期时间,超过该时间如果没有主动释放则自动释放锁,必须整数秒,单位毫秒</param>
/// <param name="throwOnFailure">失败时是否抛出异常,如果不抛出异常,可通过返回null得知申请锁失败</param>
/// <returns></returns>
public IDisposable? AcquireLock(String key, Int32 msTimeout, Int32 msExpire, Boolean throwOnFailure)
public virtual IDisposable? AcquireLock(String key, Int32 msTimeout, Int32 msExpire, Boolean throwOnFailure)
{
var rlock = new CacheLock(this, key);
if (!rlock.Acquire(msTimeout, msExpire))
Expand Down

0 comments on commit 52c2dc9

Please sign in to comment.