dotnet/aspnetcore

LoadAsync on Session - when _isNewSessionKey is true

开放

#20,898 创建于 2020年4月16日

 (10 条评论) (0 个反应) (0 位负责人)C# (10,653 个派生)batch import
Perfaffected-fewarea-middlewarebreaking-changeenhancementhelp wantedseverity-nice-to-have

仓库指标

星标
 (37,933 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

https://github.com/dotnet/aspnetcore/blob/8b000d961cd3ccfcc8090fb8368fd6598bace978/src/Middleware/Session/src/DistributedSession.cs

Should Load/LoadAsync be a no-op when _isNewSessionKey is true. Taking the advice to call LoadAsync prior to accessing the session with get/trygetvalue/set I would of thought we'd guard against unnecsssary chitchat to the cache if we know the session is new?

I though about doing Request.Cookies["sesscoookie"] != null then await LoadAsync but then doing Get/Set/Id/IsAvailable will simply call load anyway if not _loaded isnt marked.

贡献者指南