Skip to content

Commit 6f63d76

Browse files
authored
dispose (#83)
1 parent 5595f98 commit 6f63d76

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

BitFaster.Caching/Lru/TemplateConcurrentLru.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ public V GetOrAdd(K key, Func<K, V> valueFactory)
148148
return newItem.Value;
149149
}
150150

151+
if (newItem.Value is IDisposable d)
152+
{
153+
d.Dispose();
154+
}
155+
151156
return this.GetOrAdd(key, valueFactory);
152157
}
153158

@@ -171,6 +176,11 @@ public async Task<V> GetOrAddAsync(K key, Func<K, Task<V>> valueFactory)
171176
return newItem.Value;
172177
}
173178

179+
if (newItem.Value is IDisposable d)
180+
{
181+
d.Dispose();
182+
}
183+
174184
return await this.GetOrAddAsync(key, valueFactory).ConfigureAwait(false);
175185
}
176186

0 commit comments

Comments
 (0)