MemoryCacheServiceCollectionExtensions.AddDistributedMemoryCache 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| AddDistributedMemoryCache(IServiceCollection) |
新增一個預設實作 IDistributedCache ,將項目儲存在記憶體中到 IServiceCollection. 需要分散式快取運作的架構可以安全地新增此相依性作為其相依性清單的一部分,以確保至少有一個實作可供使用。 |
| AddDistributedMemoryCache(IServiceCollection, Action<MemoryDistributedCacheOptions>) |
新增一個預設實作 IDistributedCache ,將項目儲存在記憶體中到 IServiceCollection. 需要分散式快取運作的架構可以安全地新增此相依性作為其相依性清單的一部分,以確保至少有一個實作可供使用。 |
AddDistributedMemoryCache(IServiceCollection)
新增一個預設實作 IDistributedCache ,將項目儲存在記憶體中到 IServiceCollection. 需要分散式快取運作的架構可以安全地新增此相依性作為其相依性清單的一部分,以確保至少有一個實作可供使用。
public:
[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddDistributedMemoryCache(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddDistributedMemoryCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection services);
static member AddDistributedMemoryCache : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddDistributedMemoryCache (services As IServiceCollection) As IServiceCollection
參數
- services
- IServiceCollection
IServiceCollection新增服務。
傳回
這樣 IServiceCollection 可以串接額外的通話。
備註
AddDistributedMemoryCache(IServiceCollection) 應該只在單一伺服器情境中使用,因為這個快取會將項目存入記憶體,不會跨多台機器擴展。 在這些情況下,建議使用能跨多台機器擴展的分散式快取。
適用於
AddDistributedMemoryCache(IServiceCollection, Action<MemoryDistributedCacheOptions>)
新增一個預設實作 IDistributedCache ,將項目儲存在記憶體中到 IServiceCollection. 需要分散式快取運作的架構可以安全地新增此相依性作為其相依性清單的一部分,以確保至少有一個實作可供使用。
public:
[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddDistributedMemoryCache(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Action<Microsoft::Extensions::Caching::Memory::MemoryDistributedCacheOptions ^> ^ setupAction);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddDistributedMemoryCache(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.Extensions.Caching.Memory.MemoryDistributedCacheOptions> setupAction);
static member AddDistributedMemoryCache : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<Microsoft.Extensions.Caching.Memory.MemoryDistributedCacheOptions> -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddDistributedMemoryCache (services As IServiceCollection, setupAction As Action(Of MemoryDistributedCacheOptions)) As IServiceCollection
參數
- services
- IServiceCollection
IServiceCollection新增服務。
- setupAction
- Action<MemoryDistributedCacheOptions>
該 Action<T> 配置提供的 MemoryDistributedCacheOptions。
傳回
這樣 IServiceCollection 可以串接額外的通話。
備註
AddDistributedMemoryCache(IServiceCollection) 應該只在單一伺服器情境中使用,因為這個快取會將項目存入記憶體,不會跨多台機器擴展。 在這些情況下,建議使用能跨多台機器擴展的分散式快取。