Skip to content

Commit 148a556

Browse files
authored
Merge pull request #110 from dotnetcore/dev
Update documentation
2 parents f57fcb2 + fdd899d commit 148a556

File tree

8 files changed

+80
-33
lines changed

8 files changed

+80
-33
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,33 +62,33 @@ public class Startup
6262
public void ConfigureServices(IServiceCollection services)
6363
{
6464
//configuration
65-
services.AddEasyCaching(option=>
65+
services.AddEasyCaching(options =>
6666
{
6767
//use memory cache that named default
68-
option.UseInMemory("default");
68+
options.UseInMemory("default");
6969

7070
// // use memory cache with your own configuration
71-
// config.UseInMemory(options =>
71+
// options.UseInMemory(config =>
7272
// {
73-
// options.DBConfig = new InMemoryCachingOptions
73+
// config.DBConfig = new InMemoryCachingOptions
7474
// {
7575
// // scan time, default value is 60s
7676
// ExpirationScanFrequency = 60,
7777
// // total count of cache items, default value is 10000
7878
// SizeLimit = 100
7979
// };
8080
// // the max random second will be added to cache's expiration, default value is 120
81-
// options.MaxRdSecond = 120;
81+
// config.MaxRdSecond = 120;
8282
// // whether enable logging, default is false
83-
// options.EnableLogging = false;
83+
// config.EnableLogging = false;
8484
// // mutex key's alive time(ms), default is 5000
85-
// options.LockMs = 5000;
85+
// config.LockMs = 5000;
8686
// // when mutex key alive, it will sleep some time, default is 300
87-
// options.SleepMs = 300;
87+
// config.SleepMs = 300;
8888
// }, "m2");
8989
9090
//use redis cache that named redis1
91-
option.UseRedis(config =>
91+
options.UseRedis(config =>
9292
{
9393
config.DBConfig.Endpoints.Add(new ServerEndPoint("127.0.0.1", 6379));
9494
}, "redis1")

ToDoList.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
- [x] GetCount
2727
- [x] Flush/FlushAsync
2828
- [x] TrySet/TrySetAsync
29-
- [ ] GetExpiration/GetExpirationAsync
29+
- [x] GetExpiration/GetExpirationAsync
3030
- [ ] Others...
3131

3232
## Serializer Extensions

docs/AspectCore.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,36 @@ Install-Package EasyCaching.Interceptor.AspectCore
1515
1616
Install-Package EasyCaching.InMemory
1717
```
18+
1819
## 2. Define services
1920

2021
### 2.1 Define the interface
2122

22-
This interface must inherit **IEasyCaching** by default. And we need to add `EasyCachingAble`,`EasyCachingPut` and `EasyCachingEvict` to the methods that we want to simplify the caching operation.
23+
We need to add `EasyCachingAble`,`EasyCachingPut` or `EasyCachingEvict` on the methods that we want to simplify the caching operation.
24+
25+
The following unordered list shows you what the attribute will affect the caching.
2326

2427
- EasyCachingAble , Read from cached items
2528
- EasyCachingPut , Update the cached item
2629
- EasyCachingEvict , Remove one cached item or multi cached items
2730

31+
There are some properties that we should know
32+
33+
Property | Description | Apply
34+
---|---|---
35+
CacheKeyPrefix | To specify the prefix of your cache key | All
36+
CacheProviderName | To specify which provider you want to use | All
37+
IsHightAvailability | Whether caching opreation will break your method | All
38+
Expiration | To specify the expiration of your cache item,the unit is second | EasyCachingAble and EasyCachingPut
39+
IsAll | Whether remove all the cached items start with the CacheKeyPrefix | EasyCachingEvict only
40+
IsBefore | Remove the cached item before method excute or after method excute | EasyCachingEvict only
41+
42+
Here is a easy sample to show you how to use.
43+
44+
Defining a regular interface at first.
45+
2846
```csharp
29-
public interface IDemoService : EasyCaching.Core.Internal.IEasyCaching
47+
public interface IDemoService
3048
{
3149
[EasyCachingAble(Expiration = 10)]
3250
string GetCurrentUtcTime();
@@ -66,21 +84,25 @@ public class DemoService : IDemoService
6684
```csharp
6785
public class Startup
6886
{
69-
//others...
87+
// others...
7088
7189
public IServiceProvider ConfigureServices(IServiceCollection services)
7290
{
7391
services.AddScoped<IDemoService, DemoService>();
7492

7593
services.AddEasyCaching(option=>
7694
{
77-
//use memory cache
95+
// use memory cache
7896
option.UseInMemory("default");
7997
});
8098

8199
services.AddMvc();
82100

83-
return services.ConfigureAspectCoreInterceptor();
101+
return services.ConfigureAspectCoreInterceptor(options =>
102+
{
103+
// Specify which provider you want to use
104+
options.CacheProviderName = "default";
105+
});
84106
}
85107
}
86108
```

docs/CSRedis.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ And what we add in `appsettings.json` are as following:
7272
```JSON
7373
"easycaching": {
7474
"csredis": {
75-
"CachingProviderType": 2,
7675
"MaxRdSecond": 120,
77-
"Order": 2,
76+
"EnableLogging": false,
77+
"LockMs": 5000,
78+
"SleepMs": 300,
7879
"dbconfig": {
7980
"ConnectionStrings":[
8081
"127.0.0.1:6388,defaultDatabase=13,poolsize=10"

docs/Castle.md

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,41 +20,58 @@ Install-Package EasyCaching.InMemory
2020

2121
### 2.1 Define the interface
2222

23-
Just define a regular interface.
23+
We need to add `EasyCachingAble`,`EasyCachingPut` or `EasyCachingEvict` on the methods that we want to simplify the caching operation.
24+
25+
The following unordered list shows you what the attribute will affect the caching.
26+
27+
- EasyCachingAble , Read from cached items
28+
- EasyCachingPut , Update the cached item
29+
- EasyCachingEvict , Remove one cached item or multi cached items
30+
31+
There are some properties that we should know
32+
33+
Property | Description | Apply
34+
---|---|---
35+
CacheKeyPrefix | To specify the prefix of your cache key | All
36+
CacheProviderName | To specify which provider you want to use | All
37+
IsHightAvailability | Whether caching opreation will break your method | All
38+
Expiration | To specify the expiration of your cache item,the unit is second | EasyCachingAble and EasyCachingPut
39+
IsAll | Whether remove all the cached items start with the CacheKeyPrefix | EasyCachingEvict only
40+
IsBefore | Remove the cached item before method excute or after method excute | EasyCachingEvict only
41+
42+
Here is a easy sample to show you how to use.
43+
44+
Defining a regular interface at first.
2445

2546
```csharp
2647
public interface IDemoService
2748
{
49+
[EasyCachingAble(Expiration = 10)]
2850
string GetCurrentUtcTime();
2951

52+
[EasyCachingPut(CacheKeyPrefix = "Castle")]
3053
string PutSomething(string str);
3154

55+
[EasyCachingEvict(IsBefore = true)]
3256
void DeleteSomething(int id);
3357
}
3458
```
3559

36-
This implement must inherit **IEasyCaching** by default. And we need to add `EasyCachingAble`,`EasyCachingPut` and `EasyCachingEvict` to the methods that we want to simplify the caching operation.
37-
38-
- EasyCachingAble , Read from cached items
39-
- EasyCachingPut , Update the cached item
40-
- EasyCachingEvict , Remove one cached item or multi cached items
60+
Just implement the above interface.
4161

4262
```csharp
43-
public class DemoService : IDemoService , IEasyCaching
63+
public class DemoService : IDemoService
4464
{
45-
[EasyCachingEvict(IsBefore = true)]
4665
public void DeleteSomething(int id)
4766
{
4867
System.Console.WriteLine("Handle delete something..");
4968
}
5069

51-
[EasyCachingAble(Expiration = 10)]
5270
public string GetCurrentUtcTime()
5371
{
5472
return System.DateTime.UtcNow.ToString();
5573
}
5674

57-
[EasyCachingPut(CacheKeyPrefix = "Castle")]
5875
public string PutSomething(string str)
5976
{
6077
return str;
@@ -75,13 +92,17 @@ public class Startup
7592

7693
services.AddEasyCaching(option =>
7794
{
78-
//use memory cache
95+
// use memory cache
7996
option.UseInMemory("default");
8097
});
8198

8299
services.AddMvc();
83100

84-
return services.ConfigureCastleInterceptor();
101+
return services.ConfigureCastleInterceptor(options =>
102+
{
103+
// Specify which provider you want to use
104+
options.CacheProviderName = "default";
105+
});
85106
}
86107
}
87108
```

docs/Features.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
11. GetCount
1515
12. Flush/FlushAsync
1616
13. TrySet/TrySetAsync
17+
14. GetExpiration/GetExpirationAsync
1718
- Caching Providers(Both local caching and distributed caching)
1819
1. In-Memory
1920
2. Memcached

docs/In-Memory.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ And what we add in `appsettings.json` are as following:
8383
```JSON
8484
"easycaching": {
8585
"inmemory": {
86-
"CachingProviderType": 1,
8786
"MaxRdSecond": 120,
88-
"Order": 2,
87+
"EnableLogging": false,
88+
"LockMs": 5000,
89+
"SleepMs": 300,
8990
"DBConfig":{
9091
"SizeLimit": 10000,
9192
"ExpirationScanFrequency": 60

docs/Redis.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ And what we add in `appsettings.json` are as following:
6666
```JSON
6767
"easycaching": {
6868
"redis": {
69-
"CachingProviderType": 2,
7069
"MaxRdSecond": 120,
71-
"Order": 2,
70+
"EnableLogging": false,
71+
"LockMs": 5000,
72+
"SleepMs": 300,
7273
"dbconfig": {
7374
"Password": null,
7475
"IsSsl": false,

0 commit comments

Comments
 (0)