From fc564a613deca6a274889b571c1ab421376daf42 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 23 Oct 2025 19:42:16 +0000
Subject: [PATCH 1/2] Initial plan
From 5041469e3d060db2e731d4e33a766e7392b3e918 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 23 Oct 2025 19:47:08 +0000
Subject: [PATCH 2/2] Update CacheExtensions documentation to clarify
type-check behavior
Co-authored-by: jozkee <16040868+jozkee@users.noreply.github.com>
---
.../CacheExtensions.xml | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/xml/Microsoft.Extensions.Caching.Memory/CacheExtensions.xml b/xml/Microsoft.Extensions.Caching.Memory/CacheExtensions.xml
index 3ece5dae235..c4ace7e8795 100644
--- a/xml/Microsoft.Extensions.Caching.Memory/CacheExtensions.xml
+++ b/xml/Microsoft.Extensions.Caching.Memory/CacheExtensions.xml
@@ -113,9 +113,9 @@
The instance this method extends.
The key of the value to get.
- Gets the value associated with this key if present.
+ Gets the value associated with this key if present and castable to .
- The value associated with this key, or default(TItem) if the key is not present.
+ The value associated with this key, or default(TItem) if the key is not present or the stored value can't be cast to .
To be added.
@@ -595,13 +595,15 @@
The type of the object to get.
The instance this method extends.
The key of the value to get.
- The value associated with the given key.
+ The value associated with the given key, or default(TItem) if the key is not found or the stored value can't be cast to .
- Tries to get the value associated with the given key.
+ Tries to get the value associated with the given key and cast it to .
- true if the key was found; false otherwise.
- To be added.
+ true if the key was found and the stored value can be cast to ; false otherwise.
+
+ This method returns false both when the key is not present in the cache and when the key is present but the stored value can't be cast to . If you need to distinguish between these two cases (for example, in instrumented caches tracking hit/miss metrics), use the non-generic method instead, which returns true if the key is present regardless of type.
+