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: metalama-awareness-campaign/04_caching.md
+22-13Lines changed: 22 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,6 @@
1
-
2
1
Hello!
3
2
4
-
It's Fedja from Metalama again. In my previous emails, I described Metalama as a ,meta-programming _framework_ that allows you to generate and validate code as you type.
3
+
It's Fedja from Metalama again. In my previous emails, I described Metalama as a meta-programming _framework_ that allows you to generate and validate code as you type.
5
4
6
5
If you looked at our API and documentation, you may have got the impression that the framework is deep and complex.
7
6
@@ -18,33 +17,33 @@ You can add caching to your app in just three steps:
18
17
1. Add the [Metalama.Patterns.Caching.Aspects](https://www.nuget.org/packages/Metalama.Patterns.Caching.Aspects/) package to your project.
19
18
2. Navigate to all methods that need caching and add the `[Cache]` custom attribute.
20
19
21
-
20
+
22
21
```c#
23
22
usingMetalama.Patterns.Caching.Aspects;
24
-
23
+
25
24
namespaceCreatingAspects.Caching
26
25
{
27
26
publicsealedclassCloudCalculator
28
27
{
29
-
28
+
30
29
[Cache]
31
30
publicintAdd(inta, intb)
32
31
{
33
32
Console.WriteLine("Doing some very hard work.");
34
-
33
+
35
34
this.OperationCount++;
36
-
35
+
37
36
Console.WriteLine("Finished doing some very hard work.");
38
-
37
+
39
38
returna+b;
40
39
}
41
-
40
+
42
41
publicintOperationCount { get; privateset; }
43
42
}
44
43
}
45
44
```
46
45
47
-
3. Gototheapplicationstartupcodeandcall `AddMetalamaCaching`. Thisaddsthe `ICachingService` interfaceto your `IServiceCollection`, enabling the `[Cache]` aspect to be used on all objects instantiated by the DI container.
46
+
3. Gototheapplicationstartupcodeandcall `AddMetalamaCaching`. Thisaddsthe `ICachingService` interfaceto your `IServiceCollection`, enabling the `[Cache]` aspect to be used on all objects instantiated by the DI container.
48
47
49
48
```c#
50
49
builder.Services.AddMetalamaCaching();
@@ -62,7 +61,6 @@ You can add caching to your app in just three steps:
62
61
builder.Services.AddMetalamaCaching(
63
62
caching=>caching.WithBackend(
64
63
backend=>backend.Redis().WithL1() ) );
65
-
66
64
```
67
65
68
66
## What Metalama does for you
@@ -83,8 +81,19 @@ Other features of this open-source caching library include:
Ourdevelopmentteamislookingforwardtoyourfeedbackandquestionson our [Slackcommunity workspace](https://www.postsharp.net/slack). Of course, you can also answer this email and I’ll make sure it will reach an engineer.
0 commit comments