#262 prevent caching image information based on configuration to allow images to be served correctly during webp conversion process

This commit is contained in:
Hamid Reza Mohammadi 2021-12-17 12:19:59 +03:30
parent d3f14c7402
commit 356117993a
3 changed files with 19 additions and 3 deletions

View File

@ -12102,6 +12102,11 @@
طول تصویر بندانگشتی
</summary>
</member>
<member name="P:RMuseum.Services.Implementation.PictureFileService.ImageInfoCacheEnabled">
<summary>
image info cache
</summary>
</member>
<member name="P:RMuseum.Services.Implementation.PictureFileService.ImageStoragePath">
<summary>
Image Storage Path

View File

@ -151,12 +151,15 @@ namespace RMuseum.Services.Implementation
public async Task<RServiceResult<RPictureFile>> GetImage(Guid id)
{
var cachKey = $"PictureFileService::GetImage::{id}";
if (!_memoryCache.TryGetValue(cachKey, out RPictureFile pictureFile))
if (!ImageInfoCacheEnabled || !_memoryCache.TryGetValue(cachKey, out RPictureFile pictureFile))
{
pictureFile = await _context.PictureFiles.AsNoTracking()
.Where(p => p.Id == id)
.SingleOrDefaultAsync();
_memoryCache.Set(cachKey, pictureFile);
if(ImageInfoCacheEnabled)
{
_memoryCache.Set(cachKey, pictureFile);
}
}
return new RServiceResult<RPictureFile>(
@ -284,6 +287,11 @@ namespace RMuseum.Services.Implementation
/// </summary>
protected int ThumbnailImageMaxHeight { get { return int.Parse($"{Configuration.GetSection("PictureFileService")["ThumbnailMaxHeight"]}"); } }
/// <summary>
/// image info cache
/// </summary>
private bool ImageInfoCacheEnabled { get { return bool.Parse($"{Configuration.GetSection("PictureFileService")["ImageInfoCacheEnabled"]}"); } }
/// <summary>
/// Image Storage Path
@ -514,6 +522,8 @@ namespace RMuseum.Services.Implementation
}
}
/// <summary>
/// Database Contetxt
/// </summary>

View File

@ -10,7 +10,8 @@
"NormalImageMaxWidth": "800",
"NormalImageMaxHeight": "1350",
"ThumbnailImageWidth": "300",
"ThumbnailMaxHeight": "500"
"ThumbnailMaxHeight": "500",
"ImageInfoCacheEnabled": "False"
},
"Logging": {
"LogLevel": {