Skip to content

Commit ea78ede

Browse files
committed
[Doc] Doc & Changedlog updated
1 parent cf23673 commit ea78ede

File tree

13 files changed

+311
-130
lines changed

13 files changed

+311
-130
lines changed

Apizr/Docs/Apizr.Docs/api/.manifest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@
183183
"Apizr.Caching.Attributes.CacheAttributeBase.ShouldInvalidateOnError": "Apizr.Caching.Attributes.CacheAttributeBase.yml",
184184
"Apizr.Caching.Attributes.CacheKeyAttribute": "Apizr.Caching.Attributes.CacheKeyAttribute.yml",
185185
"Apizr.Caching.Attributes.CacheKeyAttribute.#ctor": "Apizr.Caching.Attributes.CacheKeyAttribute.yml",
186-
"Apizr.Caching.Attributes.CacheKeyAttribute.#ctor(System.String)": "Apizr.Caching.Attributes.CacheKeyAttribute.yml",
187-
"Apizr.Caching.Attributes.CacheKeyAttribute.PropertyName": "Apizr.Caching.Attributes.CacheKeyAttribute.yml",
186+
"Apizr.Caching.Attributes.CacheKeyAttribute.#ctor(System.String[])": "Apizr.Caching.Attributes.CacheKeyAttribute.yml",
187+
"Apizr.Caching.Attributes.CacheKeyAttribute.PropertyNames": "Apizr.Caching.Attributes.CacheKeyAttribute.yml",
188188
"Apizr.Caching.Attributes.CacheReadAllAttribute": "Apizr.Caching.Attributes.CacheReadAllAttribute.yml",
189189
"Apizr.Caching.Attributes.CacheReadAllAttribute.#ctor": "Apizr.Caching.Attributes.CacheReadAllAttribute.yml",
190190
"Apizr.Caching.Attributes.CacheReadAllAttribute.#ctor(Apizr.Caching.CacheMode)": "Apizr.Caching.Attributes.CacheReadAllAttribute.yml",

Apizr/Docs/Apizr.Docs/api/Apizr.Caching.Attributes.CacheKeyAttribute.yml

Lines changed: 63 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ items:
66
parent: Apizr.Caching.Attributes
77
children:
88
- Apizr.Caching.Attributes.CacheKeyAttribute.#ctor
9-
- Apizr.Caching.Attributes.CacheKeyAttribute.#ctor(System.String)
10-
- Apizr.Caching.Attributes.CacheKeyAttribute.PropertyName
9+
- Apizr.Caching.Attributes.CacheKeyAttribute.#ctor(System.String[])
10+
- Apizr.Caching.Attributes.CacheKeyAttribute.PropertyNames
1111
langs:
1212
- csharp
1313
- vb
@@ -26,7 +26,7 @@ items:
2626
assemblies:
2727
- Apizr
2828
namespace: Apizr.Caching.Attributes
29-
summary: Tells Apizr the key to cache value at
29+
summary: The decorated parameter will be used as cache key
3030
example: []
3131
syntax:
3232
content: >-
@@ -111,7 +111,7 @@ items:
111111
assemblies:
112112
- Apizr
113113
namespace: Apizr.Caching.Attributes
114-
summary: The decorated parameter will be used as cache key (should be primitive otherwise ToString() method will be used, unless providing a property name)
114+
summary: The decorated parameter will be used as cache key
115115
example: []
116116
syntax:
117117
content: public CacheKeyAttribute()
@@ -120,16 +120,16 @@ items:
120120
nameWithType.vb: CacheKeyAttribute.New()
121121
fullName.vb: Apizr.Caching.Attributes.CacheKeyAttribute.New()
122122
name.vb: New()
123-
- uid: Apizr.Caching.Attributes.CacheKeyAttribute.#ctor(System.String)
124-
commentId: M:Apizr.Caching.Attributes.CacheKeyAttribute.#ctor(System.String)
125-
id: '#ctor(System.String)'
123+
- uid: Apizr.Caching.Attributes.CacheKeyAttribute.#ctor(System.String[])
124+
commentId: M:Apizr.Caching.Attributes.CacheKeyAttribute.#ctor(System.String[])
125+
id: '#ctor(System.String[])'
126126
parent: Apizr.Caching.Attributes.CacheKeyAttribute
127127
langs:
128128
- csharp
129129
- vb
130-
name: CacheKeyAttribute(string)
131-
nameWithType: CacheKeyAttribute.CacheKeyAttribute(string)
132-
fullName: Apizr.Caching.Attributes.CacheKeyAttribute.CacheKeyAttribute(string)
130+
name: CacheKeyAttribute(params string[])
131+
nameWithType: CacheKeyAttribute.CacheKeyAttribute(params string[])
132+
fullName: Apizr.Caching.Attributes.CacheKeyAttribute.CacheKeyAttribute(params string[])
133133
type: Constructor
134134
source:
135135
remote:
@@ -138,57 +138,59 @@ items:
138138
repo: https://github.com/Respawnsive/Apizr.git
139139
id: .ctor
140140
path: ../../Src/Apizr/Caching/Attributes/CacheKeyAttribute.cs
141-
startLine: 23
141+
startLine: 24
142142
assemblies:
143143
- Apizr
144144
namespace: Apizr.Caching.Attributes
145145
summary: >-
146-
If you use non primitive type (like your ModelClass object) as Cache Primary key you should provide
146+
If you decorate a complex type as cache key, you may want to provide
147147
148-
property name of primitive primary Id, otherwise ToString() method will be used.
148+
its properties to include by name or to override its ToString() method.
149+
150+
Otherwise, Apizr will take all its non-null properties.
149151
example: []
150152
syntax:
151-
content: public CacheKeyAttribute(string propertyName)
153+
content: public CacheKeyAttribute(params string[] propertyNames)
152154
parameters:
153-
- id: propertyName
154-
type: System.String
155-
description: Property name.
156-
content.vb: Public Sub New(propertyName As String)
155+
- id: propertyNames
156+
type: System.String[]
157+
description: 'Properties to include as cache key (default: all non-null properties).'
158+
content.vb: Public Sub New(ParamArray propertyNames As String())
157159
overload: Apizr.Caching.Attributes.CacheKeyAttribute.#ctor*
158-
nameWithType.vb: CacheKeyAttribute.New(String)
159-
fullName.vb: Apizr.Caching.Attributes.CacheKeyAttribute.New(String)
160-
name.vb: New(String)
161-
- uid: Apizr.Caching.Attributes.CacheKeyAttribute.PropertyName
162-
commentId: P:Apizr.Caching.Attributes.CacheKeyAttribute.PropertyName
163-
id: PropertyName
160+
nameWithType.vb: CacheKeyAttribute.New(ParamArray String())
161+
fullName.vb: Apizr.Caching.Attributes.CacheKeyAttribute.New(ParamArray String())
162+
name.vb: New(ParamArray String())
163+
- uid: Apizr.Caching.Attributes.CacheKeyAttribute.PropertyNames
164+
commentId: P:Apizr.Caching.Attributes.CacheKeyAttribute.PropertyNames
165+
id: PropertyNames
164166
parent: Apizr.Caching.Attributes.CacheKeyAttribute
165167
langs:
166168
- csharp
167169
- vb
168-
name: PropertyName
169-
nameWithType: CacheKeyAttribute.PropertyName
170-
fullName: Apizr.Caching.Attributes.CacheKeyAttribute.PropertyName
170+
name: PropertyNames
171+
nameWithType: CacheKeyAttribute.PropertyNames
172+
fullName: Apizr.Caching.Attributes.CacheKeyAttribute.PropertyNames
171173
type: Property
172174
source:
173175
remote:
174176
path: Apizr/Src/Apizr/Caching/Attributes/CacheKeyAttribute.cs
175177
branch: dev
176178
repo: https://github.com/Respawnsive/Apizr.git
177-
id: PropertyName
179+
id: PropertyNames
178180
path: ../../Src/Apizr/Caching/Attributes/CacheKeyAttribute.cs
179-
startLine: 31
181+
startLine: 32
180182
assemblies:
181183
- Apizr
182184
namespace: Apizr.Caching.Attributes
183-
summary: Property name of primitive primary Id
185+
summary: 'Properties of to include as cache key (default: all non-null properties).'
184186
example: []
185187
syntax:
186-
content: public string PropertyName { get; }
188+
content: public string[] PropertyNames { get; }
187189
parameters: []
188190
return:
189-
type: System.String
190-
content.vb: Public ReadOnly Property PropertyName As String
191-
overload: Apizr.Caching.Attributes.CacheKeyAttribute.PropertyName*
191+
type: System.String[]
192+
content.vb: Public ReadOnly Property PropertyNames As String()
193+
overload: Apizr.Caching.Attributes.CacheKeyAttribute.PropertyNames*
192194
references:
193195
- uid: Apizr.Caching.Attributes
194196
commentId: N:Apizr.Caching.Attributes
@@ -2023,20 +2025,32 @@ references:
20232025
nameWithType.vb: CacheKeyAttribute.New
20242026
fullName.vb: Apizr.Caching.Attributes.CacheKeyAttribute.New
20252027
name.vb: New
2026-
- uid: System.String
2027-
commentId: T:System.String
2028-
parent: System
2028+
- uid: System.String[]
20292029
isExternal: true
20302030
href: https://learn.microsoft.com/dotnet/api/system.string
2031-
name: string
2032-
nameWithType: string
2033-
fullName: string
2034-
nameWithType.vb: String
2035-
fullName.vb: String
2036-
name.vb: String
2037-
- uid: Apizr.Caching.Attributes.CacheKeyAttribute.PropertyName*
2038-
commentId: Overload:Apizr.Caching.Attributes.CacheKeyAttribute.PropertyName
2039-
href: Apizr.Caching.Attributes.CacheKeyAttribute.html#Apizr_Caching_Attributes_CacheKeyAttribute_PropertyName
2040-
name: PropertyName
2041-
nameWithType: CacheKeyAttribute.PropertyName
2042-
fullName: Apizr.Caching.Attributes.CacheKeyAttribute.PropertyName
2031+
name: string[]
2032+
nameWithType: string[]
2033+
fullName: string[]
2034+
nameWithType.vb: String()
2035+
fullName.vb: String()
2036+
name.vb: String()
2037+
spec.csharp:
2038+
- uid: System.String
2039+
name: string
2040+
isExternal: true
2041+
href: https://learn.microsoft.com/dotnet/api/system.string
2042+
- name: '['
2043+
- name: ']'
2044+
spec.vb:
2045+
- uid: System.String
2046+
name: String
2047+
isExternal: true
2048+
href: https://learn.microsoft.com/dotnet/api/system.string
2049+
- name: (
2050+
- name: )
2051+
- uid: Apizr.Caching.Attributes.CacheKeyAttribute.PropertyNames*
2052+
commentId: Overload:Apizr.Caching.Attributes.CacheKeyAttribute.PropertyNames
2053+
href: Apizr.Caching.Attributes.CacheKeyAttribute.html#Apizr_Caching_Attributes_CacheKeyAttribute_PropertyNames
2054+
name: PropertyNames
2055+
nameWithType: CacheKeyAttribute.PropertyNames
2056+
fullName: Apizr.Caching.Attributes.CacheKeyAttribute.PropertyNames

Apizr/Docs/Apizr.Docs/articles/config_datacaching.md

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ Back to the example, we are saying:
254254

255255
#### CacheKey attribute
256256

257-
By default, Apizr will use all the method parameters (name and value) to generate a cache key (excepting property parameters, neither cancellation token parameters).
257+
By default, Apizr will use all the method parameters (name and value) to generate a cache key (excepting property parameters, neither cancellation token).
258258
But you may want to define your own cache key, choosing by yourself which parameter to include and which not.
259259
That's what the `CacheKey` attribute is made for.
260260
You can decorate one or more parameters with it, then it will be included in the cache key generation:
@@ -270,8 +270,64 @@ namespace Apizr.Sample
270270
}
271271
```
272272

273-
Cache key generation supports complex type parameters, so you can group your parameters into a single one to include them all.
274-
If you don't want them all included, but few of it, you can either provide property names to include within the CacheKey attribute constructor, or get the full control by overriding its ToString() method.
273+
Cache key generation supports complex type parameters, so you can group your parameters into a single one to include them all as cache key:
274+
```csharp
275+
public record GetUserParams
276+
{
277+
[AliasAs("userId")]
278+
public int UserId { get; init; }
279+
280+
[AliasAs("organizationId")]
281+
public int OrganizationId { get; init; }
282+
283+
[AliasAs("serviceName")]
284+
public string ServiceName { get; init; }
285+
}
286+
287+
namespace Apizr.Sample
288+
{
289+
[BaseAddress("https://reqres.in/api")]
290+
public interface IReqResService
291+
{
292+
[Get("/users/{userId}"), Cache(CacheMode.GetOrFetch, "1.00:00:00")]
293+
Task<UserDetails> GetUserAsync([Query, CacheKey] GetUserParams parameters);
294+
}
295+
}
296+
```
297+
298+
If you don't want them all included but few of it, you can provide properties to include by name within the CacheKey attribute constructor:
299+
```csharp
300+
namespace Apizr.Sample
301+
{
302+
[BaseAddress("https://reqres.in/api")]
303+
public interface IReqResService
304+
{
305+
[Get("/users/{userId}"), Cache(CacheMode.GetOrFetch, "1.00:00:00")]
306+
Task<UserDetails> GetUserAsync([Query, CacheKey("UserId", "ServiceName")] GetUserParams parameters);
307+
}
308+
}
309+
```
310+
311+
Finally, if you want to get the full control of complex type's cache key formatting, you can still override its ToString() method:
312+
```csharp
313+
public record GetUserParams
314+
{
315+
[AliasAs("userId")]
316+
public int UserId { get; init; }
317+
318+
[AliasAs("organizationId")]
319+
public int OrganizationId { get; init; }
320+
321+
[AliasAs("serviceName")]
322+
public string ServiceName { get; init; }
323+
324+
public override string ToString()
325+
{
326+
// Some custom cache key formatting
327+
return $"UserId: {UserId}";
328+
}
329+
}
330+
```
275331

276332
#### Fluent configuration
277333

Apizr/Docs/Apizr.Docs/changelog.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
6.3.0
2+
---
3+
4+
### All
5+
6+
- [New][Exceptions] Now we can **catch exceptions with a Func callback returning a Task of a handled boolean flag** thanks to `WithExCatching` fluent option
7+
- [New][Exceptions] Now we can **catch exceptions by providing a custom exception handler implementing `IApizrExceptionHandler`** thanks to `WithExCatching` fluent option
8+
- [New][ConfigureAwait] Now we can **adjust Http handlers task awaiting configuration** thanks to `ContinueOnCapturedContext` fluent option
9+
- [New][CacheKey] Now we can **choose multiple complex type's properties to be included in cache key** computation
10+
- [Fix][CacheKey] Now **providing a property name to the CacheKey attribute actually includes the property in cache key** computation as expected
11+
12+
### Apizr.Extensions.Microsoft.DependencyInjection
13+
14+
- [New][Exceptions] Now we can **catch exceptions with a Func callback providing IServiceProvider and returning a Task of a handled boolean flag** thanks to `WithExCatching` fluent option
15+
- [New][Exceptions] Now we can **catch exceptions by resolving a custom exception handler implementing `IApizrExceptionHandler`** thanks to `WithExCatching` fluent option
16+
117
6.2.0
218
---
319

Apizr/Samples/Apizr.Sample.MAUI/appsettings.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"ShouldInvalidateOnError": false
4040
}
4141
},
42-
"IReqResService": {
42+
"IReqResUserService": {
4343
"Caching": {
4444
"Mode": "FetchOrGet",
4545
"LifeSpan": "00:12:00",
@@ -49,6 +49,20 @@
4949
"HttpGet": [ "TestPipeline3" ]
5050
}
5151
},
52+
"IReqResSimpleService": {
53+
"BaseAddress": "https://reqres.in/api",
54+
"RequestTimeout": "00:00:03",
55+
"Headers": [
56+
"testSettingsKey2: testSettingsValue2.1",
57+
"testSettingsKey3: *testSettingsValue3.1*",
58+
"testSettingsKey4: {0}",
59+
"testSettingsKey5: *{0}*"
60+
],
61+
"ResiliencePipelineOptions": {
62+
"HttpGet": [ "TestPipeline3" ]
63+
}
64+
//"ResiliencePipelineKeys": [ "TestPipeline3" ]
65+
},
5266
"IHttpBinService": {
5367
"BaseAddress": "https://httpbin.org",
5468
"RequestTimeout": "00:00:04",

Apizr/Src/Apizr/Apizr.xml

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
6.3.0
2+
---
3+
4+
### All
5+
6+
- [New][Exceptions] Now we can **catch exceptions with a Func callback returning a Task of a handled boolean flag** thanks to `WithExCatching` fluent option
7+
- [New][Exceptions] Now we can **catch exceptions by providing a custom exception handler implementing `IApizrExceptionHandler`** thanks to `WithExCatching` fluent option
8+
- [New][ConfigureAwait] Now we can **adjust Http handlers task awaiting configuration** thanks to `ContinueOnCapturedContext` fluent option
9+
- [New][CacheKey] Now we can **choose multiple complex type's properties to be included in cache key** computation
10+
- [Fix][CacheKey] Now **providing a property name to the CacheKey attribute actually includes the property in cache key** computation as expected
11+
12+
### Apizr.Extensions.Microsoft.DependencyInjection
13+
14+
- [New][Exceptions] Now we can **catch exceptions with a Func callback providing IServiceProvider and returning a Task of a handled boolean flag** thanks to `WithExCatching` fluent option
15+
- [New][Exceptions] Now we can **catch exceptions by resolving a custom exception handler implementing `IApizrExceptionHandler`** thanks to `WithExCatching` fluent option
16+
117
6.2.0
218
---
319

0 commit comments

Comments
 (0)