You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the TimeZone feature, and the user does not have a TimeZone set (which is the default for new users), any requests looking to use ILocalClock will make a database query for the user, fail to find a timezone, and fail to set a cache value.
the issue is in this code
public async Task<string> GetCurrentUserTimeZoneIdAsync()
{
var userName = _httpContextAccessor.HttpContext.User?.Identity?.Name;
if (string.IsNullOrEmpty(userName))
{
return null;
}
var key = GetCacheKey(userName);
var timeZoneId = await _distributedCache.GetStringAsync(key);
if (string.IsNullOrEmpty(timeZoneId))
{
var user = await _userManager.FindByNameAsync(userName) as User;
timeZoneId = user.As<UserTimeZone>()?.TimeZoneId;
if (!string.IsNullOrEmpty(timeZoneId))
{
await _distributedCache.SetStringAsync(key, timeZoneId, new DistributedCacheEntryOptions { SlidingExpiration = _slidingExpiration });
}
}
return timeZoneId;
}
where it might be appropriate to set a NoValueFound cache value, to prevent this.
current workaround is to use user event handlers to force set the usertime zone as they are created to the sites timezone, but this has other issues.
the code above looks like it needs a rework, as it's sliding at one minute, which is a bit low if you're expecting performance.
The text was updated successfully, but these errors were encountered:
When using the TimeZone feature, and the user does not have a TimeZone set (which is the default for new users), any requests looking to use
ILocalClock
will make a database query for the user, fail to find a timezone, and fail to set a cache value.the issue is in this code
where it might be appropriate to set a
NoValueFound
cache value, to prevent this.current workaround is to use user event handlers to force set the usertime zone as they are created to the sites timezone, but this has other issues.
the code above looks like it needs a rework, as it's sliding at one minute, which is a bit low if you're expecting performance.
The text was updated successfully, but these errors were encountered: