Skip to content

Commit 5dcfe16

Browse files
committed
Caching delete all fix
1 parent 3c0a812 commit 5dcfe16

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎src/Incoding.Core/Block/Caching/Providers/NetCachedProvider.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Incoding.Core.Block.Caching.Providers
55
{
66
public sealed class NetCachedProvider : ICachedProvider
77
{
8-
private IMemoryCache _memoryCache;
8+
private MemoryCache _memoryCache;
99

1010
private Func<IMemoryCache> _getCache;
1111

@@ -15,7 +15,7 @@ public NetCachedProvider()
1515
{
1616
if (_getCache == null)
1717
_getCache = () => new MemoryCache(new MemoryCacheOptions());
18-
_memoryCache = _getCache();
18+
_memoryCache = (MemoryCache)_getCache();
1919
}
2020

2121
public NetCachedProvider(Func<IMemoryCache> getCache) : this()
@@ -35,8 +35,8 @@ public void Set<T>(string key, T instance, CacheOptions cacheOptions)
3535

3636
public void DeleteAll()
3737
{
38-
_memoryCache.Dispose();
39-
_memoryCache = _getCache();
38+
_memoryCache.Compact(1.0);
39+
//_memoryCache = (MemoryCache)_getCache();
4040
}
4141

4242
public void Delete(string key)

‎src/Incoding.WebTest30/Operations/GetItemsQuery.cs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ public class ClearItemCacheCommand : CommandBase
1313
{
1414
protected override void Execute()
1515
{
16-
CachingFactory.Instance.Delete(new GetItemsQuery());
17-
CachingFactory.Instance.Delete(new GetItems1Query());
16+
//CachingFactory.Instance.Delete(new GetItemsQuery());
17+
//CachingFactory.Instance.Delete(new GetItems1Query());
18+
CachingFactory.Instance.DeleteAll();
1819
}
1920
}
2021

0 commit comments

Comments
 (0)