Skip to content

Commit

Permalink
🐛 Fix bug of InMemory provider.
Browse files Browse the repository at this point in the history
  • Loading branch information
catcherwong committed Jan 5, 2019
1 parent 85290ea commit 38697ce
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/EasyCaching.InMemory/DefaultInMemoryCachingProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -725,17 +725,11 @@ public bool TrySet<T>(string cacheKey, T cacheValue, TimeSpan expiration)
ArgumentCheck.NotNull(cacheValue, nameof(cacheValue));
ArgumentCheck.NotNegativeOrZero(expiration, nameof(expiration));

if (_cacheKeys.Contains(cacheKey))
if (_cacheKeys.Contains(BuildCacheKey(Name, cacheKey)))
{
return false;
}

if (MaxRdSecond > 0)
{
var addSec = new Random().Next(1, MaxRdSecond);
expiration.Add(new TimeSpan(0, 0, addSec));
}

Set(cacheKey, cacheValue, expiration);
return true;
}
Expand All @@ -754,17 +748,11 @@ public async Task<bool> TrySetAsync<T>(string cacheKey, T cacheValue, TimeSpan e
ArgumentCheck.NotNull(cacheValue, nameof(cacheValue));
ArgumentCheck.NotNegativeOrZero(expiration, nameof(expiration));

if (_cacheKeys.Contains(cacheKey))
if (_cacheKeys.Contains(BuildCacheKey(Name, cacheKey)))
{
return false;
}

if (MaxRdSecond > 0)
{
var addSec = new Random().Next(1, MaxRdSecond);
expiration.Add(new TimeSpan(0, 0, addSec));
}

await SetAsync(cacheKey, cacheValue, expiration);
return true;
}
Expand Down

0 comments on commit 38697ce

Please sign in to comment.