diff --git a/LiteDB.Shell/LiteDB.Shell.csproj b/LiteDB.Shell/LiteDB.Shell.csproj index af93887d3..f0b30da47 100644 --- a/LiteDB.Shell/LiteDB.Shell.csproj +++ b/LiteDB.Shell/LiteDB.Shell.csproj @@ -1,4 +1,4 @@ - + netcoreapp2.0 diff --git a/LiteDB/Engine/Services/CacheService.cs b/LiteDB/Engine/Services/CacheService.cs index 9ff8112aa..ca8f467ab 100644 --- a/LiteDB/Engine/Services/CacheService.cs +++ b/LiteDB/Engine/Services/CacheService.cs @@ -1,11 +1,18 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; + +#if !NET35 +using System.Collections.Concurrent; +#endif namespace LiteDB { internal class CacheService { + +#if NET35 /// /// Collection to store clean only pages in cache /// @@ -15,6 +22,17 @@ internal class CacheService /// Collection to store dirty only pages in cache. If page was in _clean, remove from there and insert here /// private Dictionary _dirty = new Dictionary(); +#else + /// + /// Collection to store clean only pages in cache + /// + private ConcurrentDictionary _clean = new ConcurrentDictionary(); + + /// + /// Collection to store dirty only pages in cache. If page was in _clean, remove from there and insert here + /// + private ConcurrentDictionary _dirty = new ConcurrentDictionary(); +#endif private IDiskService _disk; private Logger _log; @@ -58,7 +76,11 @@ public void AddPage(BasePage page) /// public void SetDirty(BasePage page) { +#if NET35 _clean.Remove(page.PageID); +#else + _clean.TryRemove(page.PageID, out _); +#endif page.IsDirty = true; _dirty[page.PageID] = page; } @@ -114,11 +136,8 @@ public void MarkDirtyAsClean() /// public void ClearPages() { - lock(_clean) - { - _log.Write(Logger.CACHE, "cleaning cache"); - _clean.Clear(); - } + _log.Write(Logger.CACHE, "cleaning cache"); + _clean.Clear(); } } -} \ No newline at end of file +} diff --git a/LiteDB/LiteDB.csproj b/LiteDB/LiteDB.csproj index d3e245ddb..7c5242767 100644 --- a/LiteDB/LiteDB.csproj +++ b/LiteDB/LiteDB.csproj @@ -1,4 +1,4 @@ - + netstandard1.3;netstandard2.0