Skip to content

Commit 945d832

Browse files
committed
Updated README.md and NuGet description and bump version to 1.0.0
1 parent 756aab5 commit 945d832

File tree

2 files changed

+37
-36
lines changed

2 files changed

+37
-36
lines changed

README.md

+34-33
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Add `<SpatialFocus.MethodCache/>` to [FodyWeavers.xml](https://github.com/Fody/H
2929

3030
```xml
3131
<Weavers>
32-
<SpatialFocus.MethodCache/>
32+
<SpatialFocus.MethodCache/>
3333
</Weavers>
3434
```
3535

@@ -41,18 +41,19 @@ Before code:
4141
[Cache]
4242
public class BasicSample
4343
{
44-
public BasicSample(IMemoryCache memoryCache)
45-
{
46-
MemoryCache = memoryCache;
47-
}
48-
49-
// MethodCache.Fody will look for a property implementing the Microsoft.Extensions.Caching.Memory.IMemoryCache interface
50-
protected IMemoryCache MemoryCache { get; }
51-
52-
public int Add(int a, int b)
53-
{
54-
return a + b;
55-
}
44+
public BasicSample(IMemoryCache memoryCache)
45+
{
46+
MemoryCache = memoryCache;
47+
}
48+
49+
// MethodCache.Fody will look for a property implementing
50+
// the Microsoft.Extensions.Caching.Memory.IMemoryCache interface
51+
protected IMemoryCache MemoryCache { get; }
52+
53+
public int Add(int a, int b)
54+
{
55+
return a + b;
56+
}
5657
}
5758
```
5859

@@ -62,30 +63,30 @@ What gets compiled
6263
[Cache]
6364
public class BasicSample
6465
{
65-
public BasicSample(IMemoryCache memoryCache)
66-
{
67-
MemoryCache = memoryCache;
68-
}
69-
70-
protected IMemoryCache MemoryCache { get; }
66+
public BasicSample(IMemoryCache memoryCache)
67+
{
68+
MemoryCache = memoryCache;
69+
}
7170

72-
public int Add(int a, int b)
73-
{
74-
// Create a unique cache key, based on namespace, class name and method name as first parameter and corresponding
75-
// generic class parameters, generic method parameters and method parameters
76-
Tuple<string, int, int> key = new Tuple<string, int, int>("Namespace.BasicSample.Add", a, b);
71+
protected IMemoryCache MemoryCache { get; }
7772

78-
// Check and return if a cached value exists for key
79-
if (MemoryCache.TryGetValue(key, out int value))
73+
public int Add(int a, int b)
8074
{
81-
return value;
75+
// Create a unique cache key, based on namespace, class name and method name as first parameter
76+
// and corresponding generic class parameters, generic method parameters and method parameters
77+
Tuple<string, int, int> key = new Tuple<string, int, int>("Namespace.BasicSample.Add", a, b);
78+
79+
// Check and return if a cached value exists for key
80+
if (MemoryCache.TryGetValue(key, out int value))
81+
{
82+
return value;
83+
}
84+
85+
// Before each return statement, save the value that would be returned in the cache
86+
value = a + b;
87+
MemoryCache.Set<int>(key, value);
88+
return value;
8289
}
83-
84-
// Before each return statement, save the value that would be returned in the cache
85-
value = a + b;
86-
MemoryCache.Set<int>(key, value);
87-
return value;
88-
}
8990
}
9091
```
9192

src/SpatialFocus.MethodCache/SpatialFocus.MethodCache.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>net472;netstandard2.0</TargetFrameworks>
5-
<Version>1.0.0-alpha1</Version>
6-
<Title>A method caching Fody addin.</Title>
5+
<Version>1.0.0</Version>
6+
<Title>A method cache Fody plugin.</Title>
77
<Authors>Dresel,pergerch</Authors>
88
<Company>SpatialFocus</Company>
9-
<Description>Allows the use of a [Cache] attribute to cache results of method calls of entire classes or only certain methods.</Description>
9+
<Description>A method cache Fody plugin. Caches return values of methods decorated with a [Cache] Attribute. Integrates with the .NET Extension IMemoryCache interface.</Description>
1010
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1111
<PackageTags>Caching, ILWeaving, Fody, Cecil, AOP</PackageTags>
1212
<PackageOutputPath>$(SolutionDir)\.nuget</PackageOutputPath>

0 commit comments

Comments
 (0)