From fb8b1f1a1f10a045733e472d037329339c55fe65 Mon Sep 17 00:00:00 2001 From: Alexander Yumashev <33555768+alex-jitbit@users.noreply.github.com> Date: Sat, 4 May 2024 13:19:50 +0300 Subject: [PATCH] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 807f2ee..d683ef3 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,13 @@ cache.GetOrAdd( valueFactory: k => 42, ttl: TimeSpan.FromMilliseconds(100)); +//handy overload to prevent captures/closures allocation +cache.GetOrAdd( + key: "answer", + valueFactory: (k, arg) => 42 + arg.Length, + ttl: TimeSpan.FromMilliseconds(100), + factoryArgument: "some state data"); + ``` ## Tradeoffs