Skip to content

Commit 5107e1d

Browse files
committed
explicit confused key example
1 parent ff5055d commit 5107e1d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

aspnetcore/performance/caching/hybrid.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,13 @@ It's the caller's responsibility to ensure that a key scheme is valid and can't
7878
* `orderid` and `userId` are internally generated identifiers.
7979
* `region` might be an enum or string from a predefined list of known regions.
8080

81-
There is no significance placed on tokens such as `/` or `_`. The entire key value is treated as an opaque identifying string. You could omit the `/` and `_` with no change to the way the cache functions.
81+
There is no significance placed on tokens such as `/` or `_`. The entire key value is treated as an opaque identifying string. In this case, you could omit the `/` and `_` with no
82+
change to the way the cache functions, but a delimiter is usually used to avoid ambiguity - for example `$"order{customerId}{orderId}"` could cause confusion betwen:
83+
84+
- `customerId` 42 with `orderId` 123
85+
- `customerId` 421 with `orderId` 23
86+
87+
(both of which would generate the cache key `order42123`)
8288

8389
This guidance applies equally to any `string`-based cache API, such as `HybridCache`, `IDistributedCache`, and `IMemoryCache`.
8490

0 commit comments

Comments
 (0)