diff --git a/FastCache/FastCache.cs b/FastCache/FastCache.cs index edb69ec..ff7b63f 100644 --- a/FastCache/FastCache.cs +++ b/FastCache/FastCache.cs @@ -64,7 +64,7 @@ public void AddOrUpdate(TKey key, TValue value, TimeSpan ttl) { var ttlValue = new TtlValue(value, ttl); - _dict.AddOrUpdate(key, ttlValue, (k, v) => ttlValue); + _dict.AddOrUpdate(key, (k, c) => c, (k, v, c) => c, ttlValue); } /// @@ -153,7 +153,7 @@ public TValue GetOrAdd(TKey key, Func valueFactory, TimeSpan ttl) if (TryGet(key, out var value)) return value; - return _dict.GetOrAdd(key, (k, v) => new TtlValue(valueFactory(k), v), ttl).Value; + return _dict.GetOrAdd(key, (k, v) => new TtlValue(v.valueFactory(k), v.ttl), (ttl, valueFactory)).Value; } ///