AppFabric 会话状态提供程序 - 已为用于存储会话的缓存禁用 LRU 逐出

AppFabric session state provider - LRU eviction has been disabled for the cache used to store Session

我正在使用 AppFabric 在 2 个或更多不同的 Web 应用程序之间共享会话。

但我遇到了一个问题:“预期会话项 'FULL_NAME' 存在于缓存中,但找不到,表明当前会话已损坏。请验证用于存储 Session 的缓存是否已禁用 LRU 逐出。"

我的配置:

<dataCacheClient>
<hosts>
  <host name="CACHE1" cachePort="22233" />
  <host name="CACHE2" cachePort="22233" />
  <host name="CACHE3" cachePort="22233" />
</hosts>

<machineKey validationKey="C7415df6847D0C0B5146F5605B5973EBD59kjh67EE6414ECD534A95F528F153B6B5F42CFFA9EBF65B2169F7DA5D801C0F9053454A159505253DC687A" decryptionKey="3AE9EE73F1A2781B73DEC6C3fgdgdfD28E0C730284DD314118DA8B" validation="SHA1" decryption="AES" />

<sessionState timeout="40" mode="Custom" customProvider="AFCacheSessionStateProvider">
  <providers>
    <add name="AFCacheSessionStateProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" cacheName="XXXXX" shareID="YYYYY" retryCount="10" useBlobMode="false" />
  </providers>
</sessionState>

有谁知道是什么问题吗?

您需要检查的不是 asp.net 配置,而是缓存本身。

在缓存主机上,查看命令 Get-CacheConfig XXXXX 的输出 - 正如 docs 所说,您将看到这样的输出:检查 EvictionType:

CacheName            : Cache1
TimeToLive           : 10 mins
CacheType            : Partitioned
Secondaries          : 0
IsExpirable          : True
EvictionType         : LRU
NotificationsEnabled : False

有关逐出设置的详细信息,请参阅 Expiration and Eviction 文档。如果您的驱逐类型不是 LRU,请检查缓存内存使用情况,如该页面所述:

When the memory consumption of the cache service on a cache server exceeds the low watermark threshold, AppFabric starts evicting objects that have already expired. When memory consumption exceeds the high watermark threshold, objects are evicted from memory, regardless of whether they have expired or not, until memory consumption goes back down to the low watermark.

有一个包含更多信息的 expiration troubleshooting 页面。