Skip to content

Commit 81c55ca

Browse files
committed
Update caching.md
1 parent 1ba503f commit 81c55ca

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

MyApp/_pages/caching.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ To configure which cache should be used, the particular client has to be registe
5353

5454
By default ServiceStack registers an MemoryCacheClient by default when no `ICacheClient` is registered so no registration is necessary.
5555

56-
```csharp
57-
//container.Register<ICacheClient>(new MemoryCacheClient());
56+
```csharp
57+
//services.AddSingleton<ICacheClient>(new MemoryCacheClient());
5858
```
5959

6060
Even if you have an alternative `ICacheClient` registered you can still access the in memory cache via the `LocalCache` property in your Services
@@ -63,11 +63,11 @@ and ServiceStack MVC Controllers or anywhere else via the `HostContext.AppHost.G
6363

6464
### Redis
6565

66-
```csharp
67-
container.Register<IRedisClientsManager>(c =>
66+
```csharp
67+
services.AddSingleton<IRedisClientsManager>(c =>
6868
new RedisManagerPool("localhost:6379"));
6969

70-
container.Register(c => c.Resolve<IRedisClientsManager>().GetCacheClient());
70+
services.AddSingleton(c => c.GetRequiredService<IRedisClientsManager>().GetCacheClient());
7171
```
7272

7373
##### NuGet Package: [ServiceStack.Redis](http://www.nuget.org/packages/ServiceStack.Redis)
@@ -113,7 +113,8 @@ var awsDb = new AmazonDynamoDBClient(
113113
AWS_ACCESS_KEY, AWS_SECRET_KEY, RegionEndpoint.USEast1);
114114

115115
services.AddSingleton<IPocoDynamo>(new PocoDynamo(awsDb));
116-
services.AddSingleton<ICacheClient>(c => new DynamoDbCacheClient(c.Resolve<IPocoDynamo>()));
116+
services.AddSingleton<ICacheClient>(c =>
117+
new DynamoDbCacheClient(c.GetRequiredService<IPocoDynamo>()));
117118

118119
var cache = appHost.Resolve<ICacheClient>();
119120
cache.InitSchema();
@@ -138,7 +139,7 @@ and redis server backed Cache Client with:
138139
```csharp
139140
services.AddSingleton<ICacheClient>(c => new MultiCacheClient(
140141
new MemoryCacheClient(),
141-
c.Resolve<IRedisClientsManager>().GetCacheClient()));
142+
c.GetRequiredService<IRedisClientsManager>().GetCacheClient()));
142143
```
143144

144145
## Cache a response of a service

0 commit comments

Comments
 (0)