1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-23 17:07:42 +01:00

setting for disabling icons cache

This commit is contained in:
Kyle Spearrin 2018-06-18 08:31:37 -04:00
parent de552be25f
commit 7ee659e3b1
3 changed files with 4 additions and 2 deletions

View File

@ -49,7 +49,7 @@ namespace Bit.Icons.Controllers
}
var mappedDomain = _domainMappingService.MapDomain(domain);
if(!_memoryCache.TryGetValue(mappedDomain, out Icon icon))
if(!_iconsSettings.CacheEnabled || !_memoryCache.TryGetValue(mappedDomain, out Icon icon))
{
var result = await _iconFetchingService.GetIconAsync(domain);
if(result == null)
@ -62,7 +62,7 @@ namespace Bit.Icons.Controllers
}
// Only cache not found and smaller images (<= 50kb)
if(icon == null || icon.Image.Length <= 50012)
if(_iconsSettings.CacheEnabled && (icon == null || icon.Image.Length <= 50012))
{
_memoryCache.Set(mappedDomain, icon, new MemoryCacheEntryOptions
{

View File

@ -2,6 +2,7 @@
{
public class IconsSettings
{
public virtual bool CacheEnabled { get; set; }
public virtual int CacheHours { get; set; }
public virtual long? CacheSizeLimit { get; set; }
}

View File

@ -13,6 +13,7 @@
}
},
"iconsSettings": {
"cacheEnabled": true,
"cacheHours": 24,
"cacheSizeLimit": null
}