You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/performance/caching/hybrid.md
+12-2Lines changed: 12 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -94,7 +94,7 @@ Notice that the inline interpolated string syntax (`$"..."` in the preceding exa
94
94
95
95
* Keys can be restricted to valid maximum lengths. For example, the default `HybridCache` implementation (via `AddHybridCache(...)`) restricts keys to 1024 characters by default. That number is configurable via `HybridCacheOptions.MaximumKeyLength`, with longer keys bypassing the cache mechanisms to prevent saturation.
96
96
* Keys must be valid Unicode sequences. If invalid Unicode sequences are passed, the behavior is undefined.
97
-
* When using an out-of-process secondary cache such as `IDistributedCache`, the specific backend implementation may impose additional restrictions. As a hypothetical example, a particular backend might use case-insensitive key logic. The default `HybridCache` (via `AddHybridCache(...)`) detects this scenario to prevent confusion attacks, however it may still result in conflicting keys becoming overwritten or evicted sooner than expected.
97
+
* When using an out-of-process secondary cache such as `IDistributedCache`, the specific backend implementation may impose additional restrictions. As a hypothetical example, a particular backend might use case-insensitive key logic. The default `HybridCache` (via `AddHybridCache(...)`) detects this scenario to prevent confusion/alias attacks (using bitwise string equality), however it may still result in conflicting keys becoming overwritten or evicted sooner than expected.
98
98
99
99
### The alternative `GetOrCreateAsync` overload
100
100
@@ -128,7 +128,17 @@ Set tags when calling `GetOrCreateAsync`, as shown in the following example:
128
128
129
129
Remove all entries for a specified tag by calling [`RemoveByTagAsync`](https://source.dot.net/#Microsoft.Extensions.Caching.Hybrid/Runtime/HybridCache.cs,c37a54f5e962ab23) with the tag value. An [overload](https://source.dot.net/#Microsoft.Extensions.Caching.Hybrid/Runtime/HybridCache.cs,9efbe8770df53e9c) lets you specify a collection of tag values.
130
130
131
-
When an entry is removed, it is removed from both the primary and secondary caches.
131
+
Note that because neither `IMemoryCache` nor `IDistributedCache` have direct support for the concept of tags (and tag-based invalidation), this is a *logical* operation only; it does not actively remove values from either local or distributed cache. Instead, it ensures that when receiving data with such tags, the data will be treated as a cache-miss from both the local and remote cache. The values will expire from `IMemoryCache` and `IDistributedCache` in the usual way based on the configured lifetime.
132
+
133
+
## Removing all cache entries
134
+
135
+
The tag `*` is reserved as a wildcard and is disallowed against individual values. Calling `RemoveByTagAsync("*")` has the effect of invalidating *all*`HybridCache` data, even data that does not have any tags. As with individual tags, this is a *logical* operation, and individual values may continue to exist until they expire naturally. Glob-style matches are not supported (you cannot use `RemoveByTagAsync("foo*)` to remove everything
136
+
starting with `"foo"`).
137
+
138
+
### Additional tag considerations
139
+
140
+
* The system does not enforce an upper-limit on the number of tags, but excessively large sets of tags may have performance implications
141
+
* Tags cannot be empty or just whitespace, and cannot be the reserved value `"*"`
0 commit comments