Is there an existing issue for this?
Describe the bug
As part of f99b482 code is DistributedSession.CommitsAsync was modified to check IsAvailable.
|
public async Task CommitAsync(CancellationToken cancellationToken = default) |
IsAvailable always loads session from backing store and loads it in synchronous way.
On the other hand SessionMiddleware always calls DistributedSession.CommitAsync to save session. This means that in 6.0 session is always loaded even if application code did not touch it at all. In case of using Redis as backing store this incurs two Redis calls on each RazorPage rendered.
|
await feature.Session.CommitAsync(); |
In the past (5.0) when session was not touched DistributedSession._isModified prevented session data from being loaded when session was not modified.
@pranavkm Could you tell why IsAvailable was moved?
Expected Behavior
Don't loading session data from backing store when session data is not modified by app code.
.NET Version
6.0.300
Is there an existing issue for this?
Describe the bug
As part of f99b482 code is
DistributedSession.CommitsAsyncwas modified to checkIsAvailable.aspnetcore/src/Middleware/Session/src/DistributedSession.cs
Line 263 in 4aa4ec3
IsAvailablealways loads session from backing store and loads it in synchronous way.aspnetcore/src/Middleware/Session/src/DistributedSession.cs
Line 96 in 4aa4ec3
On the other hand
SessionMiddlewarealways callsDistributedSession.CommitAsyncto save session. This means that in 6.0 session is always loaded even if application code did not touch it at all. In case of using Redis as backing store this incurs two Redis calls on each RazorPage rendered.aspnetcore/src/Middleware/Session/src/SessionMiddleware.cs
Line 119 in 4aa4ec3
In the past (5.0) when session was not touched
DistributedSession._isModifiedprevented session data from being loaded when session was not modified.aspnetcore/src/Middleware/Session/src/DistributedSession.cs
Line 274 in 4aa4ec3
@pranavkm Could you tell why
IsAvailablewas moved?Expected Behavior
Don't loading session data from backing store when session data is not modified by app code.
.NET Version
6.0.300