Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 4009782

Browse files
committed
Merge pull request #270 from github/fixes/fix-horrible-cache-leak
Cache blob caches
2 parents be5bb2b + 80c405e commit 4009782

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/GitHub.App/Factories/SqlitePersistentBlobCacheFactory.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Akavache.Sqlite3;
33
using NLog;
44
using System;
5+
using System.Collections.Generic;
56
using System.ComponentModel.Composition;
67

78
namespace GitHub.Factories
@@ -11,14 +12,19 @@ namespace GitHub.Factories
1112
public class SqlitePersistentBlobCacheFactory : IBlobCacheFactory
1213
{
1314
static readonly Logger log = LogManager.GetCurrentClassLogger();
15+
Dictionary<string, IBlobCache> cache = new Dictionary<string, IBlobCache>();
1416

1517
public IBlobCache CreateBlobCache(string path)
1618
{
1719
Guard.ArgumentNotEmptyString(path, nameof(path));
20+
if (cache.ContainsKey(path))
21+
return cache[path];
1822

1923
try
2024
{
21-
return new SQLitePersistentBlobCache(path);
25+
var c = new SQLitePersistentBlobCache(path);
26+
cache.Add(path, c);
27+
return c;
2228
}
2329
catch(Exception ex)
2430
{

0 commit comments

Comments
 (0)