diff --git a/docs/en/Community-Articles/2024-11-01-Hybrid-Cache-Net-9/POST.md b/docs/en/Community-Articles/2024-11-01-Hybrid-Cache-Net-9/POST.md index 615417b209..65f93d415c 100644 --- a/docs/en/Community-Articles/2024-11-01-Hybrid-Cache-Net-9/POST.md +++ b/docs/en/Community-Articles/2024-11-01-Hybrid-Cache-Net-9/POST.md @@ -29,6 +29,9 @@ To demonstrate how to use **HybridCache** in ABP, let's start with a simple exam First, you can configure the hybrid cache options in your module class as below (it's optional): ```csharp +using Microsoft.Extensions.Caching.Hybrid; +using Volo.Abp.Caching.Hybrid; + public class YourModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) @@ -38,7 +41,7 @@ public class YourModule : AbpModule Configure(options => { //configuring the global hybrid cache options - option.GlobalHybridCacheEntryOptions = new HybridCacheEntryOptions() + options.GlobalHybridCacheEntryOptions = new HybridCacheEntryOptions() { Expiration = TimeSpan.FromMinutes(20), LocalCacheExpiration = TimeSpan.FromMinutes(10) @@ -56,24 +59,14 @@ public class YourModule : AbpModule After the configuration, now you can inject the `IHybridCache` and use it to set and retrieve cache values: ```csharp -public class BookCacheItem -{ - public string Name { get; set; } - - public int PageCount { get; set; } -} +using Volo.Abp.Caching.Hybrid; -public class BookAppService : IBookAppService, ITransientDependency +public class BookAppService : ApplicationService, IBookAppService { - private readonly IBookRepository _bookRepository; private readonly IHybridCache _hybridCache; - public BookAppService( - IBookRepository bookRepository, - IHybridCache hybridCache - ) + public BookAppService(IHybridCache hybridCache) { - _bookRepository = bookRepository; _hybridCache = hybridCache; } @@ -93,6 +86,13 @@ public class BookAppService : IBookAppService, ITransientDependency }); } } + +public class BookCacheItem +{ + public string Name { get; set; } + + public int PageCount { get; set; } +} ``` * You can use the `IHybridCache` or `IHybridCache` service to leverage the hybrid caching. If you use `IHybridCache`as the service, then you should pass the cache key as *string* like in the example above.