Skip to content

Latest commit

 

History

History

Infra.Caching.Memory

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Infra.Caching.Memory

透過 Microsoft.Extensions.Caching.Memory 實現記憶體快取機制。
Implement memory cache mechanism with Microsoft.Extensions.Caching.Memory.

How to use

新增記憶體快取實例至 DI 容器中。

  1. Add memory cache instance to DI container

    builder.Services.AddMemoryCache();
    
    // MemoryCache namespace from Infra.Caching.Memory, not from Microsoft.Extensions.Caching.Memory!
    builder.Services.AddSingleton<ICache, MemoryCache>();

注入 ICache 來使用記憶體快取。

  1. Inject ICache to use memory cache.