dotnet / dotnet/aspnetcore

LoadAsync on Session - when _isNewSessionKey is true

Open
#20,898 10 comments 0 reactions 0 assignees View on GitHub
affected-few area-middleware breaking-change enhancement help wanted Perf severity-nice-to-have
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.