Skip to content

Commit ea39852

Browse files
committed
Remove SQLite cache
1 parent 1384af8 commit ea39852

File tree

3 files changed

+10
-149
lines changed

3 files changed

+10
-149
lines changed

Files/Files.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,6 @@
266266
<Compile Include="Helpers\Extension.cs" />
267267
<Compile Include="Helpers\FileListCache\FileListCacheController.cs" />
268268
<Compile Include="Helpers\FileListCache\IFileListCache.cs" />
269-
<Compile Include="Helpers\FileListCache\PersistentSQLiteCacheAdapter.cs" />
270269
<Compile Include="Helpers\ExtensionManager.cs" />
271270
<Compile Include="Helpers\IntervalSampler.cs" />
272271
<Compile Include="Helpers\QuickLookHelpers.cs" />
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Files.Common;
2-
using System.Collections.Generic;
1+
using System.Collections.Concurrent;
32
using System.Threading;
43
using System.Threading.Tasks;
54

@@ -14,40 +13,31 @@ public static FileListCacheController GetInstance()
1413
return instance ??= new FileListCacheController();
1514
}
1615

17-
private readonly IFileListCache persistentAdapter;
18-
1916
private FileListCacheController()
2017
{
21-
persistentAdapter = new PersistentSQLiteCacheAdapter();
2218
}
2319

24-
private readonly Dictionary<string, object> fileNamesCache = new Dictionary<string, object>();
20+
private readonly ConcurrentDictionary<string, string> fileNamesCache = new ConcurrentDictionary<string, string>();
2521

26-
public async Task<string> ReadFileDisplayNameFromCache(string path, CancellationToken cancellationToken)
22+
public Task<string> ReadFileDisplayNameFromCache(string path, CancellationToken cancellationToken)
2723
{
28-
var displayName = fileNamesCache.Get(path, (string)null);
29-
if (displayName == null)
24+
if (fileNamesCache.TryGetValue(path, out var displayName))
3025
{
31-
displayName = await persistentAdapter.ReadFileDisplayNameFromCache(path, cancellationToken);
32-
if (displayName != null)
33-
{
34-
fileNamesCache[path] = displayName;
35-
}
26+
return Task.FromResult(displayName);
3627
}
37-
return displayName;
28+
29+
return Task.FromResult<string>(null);
3830
}
3931

4032
public Task SaveFileDisplayNameToCache(string path, string displayName)
4133
{
4234
if (displayName == null)
4335
{
44-
fileNamesCache.Remove(path);
45-
return persistentAdapter.SaveFileDisplayNameToCache(path, displayName);
36+
fileNamesCache.TryRemove(path, out _);
4637
}
47-
fileNamesCache[path] = displayName;
4838

49-
// save entry to persistent cache in background
50-
return persistentAdapter.SaveFileDisplayNameToCache(path, displayName);
39+
fileNamesCache[path] = displayName;
40+
return Task.CompletedTask;
5141
}
5242
}
5343
}

Files/Helpers/FileListCache/PersistentSQLiteCacheAdapter.cs

-128
This file was deleted.

0 commit comments

Comments
 (0)