Skip to content

Commit

Permalink
📝 Add GetRedisProvider for factory
Browse files Browse the repository at this point in the history
  • Loading branch information
catcherwong committed Apr 27, 2019
1 parent 213a954 commit 58bc913
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/ProviderFactory.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ After releasing v0.4.0 of EasyCaching, we can deal with this scenario.

This usage of `EasyCachingProviderFactory` is similar with `HttpClientFactory`.

There are two types of providers(`IEasyCachingProvider` and `IRedisCachingProvider`) can use `EasyCachingProviderFactory` to create.

Here use two InMemory caching provders and two Redis caching providers to show.

## 1. Install the packages via Nuget
Expand Down Expand Up @@ -116,5 +118,21 @@ public class ValuesController : Controller
Console.WriteLine($"Type=redis2,Key=named-provider,Value={res},Time:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
return $"cached value : {res}";
}

// GET api/values/redis3
[HttpGet]
[Route("redis3")]
public string GetRedis3()
{
var redis1 = factory.GetRedisProvider("redis1");
var redis2 = factory.GetRedisProvider("redis2");

_redis1.StringSet("keyredis1", "val");

var res1 = _redis1.StringGet("keyredis1");
var res2 = _redis2.StringGet("keyredis1");

return $"redis1 cached value: {res1}, redis2 cached value : {res2}";
}
}
```

0 comments on commit 58bc913

Please sign in to comment.