* dnsfilter: use golibs/cache

+ config: add cache size settings
+ config: add cache_time setting
This commit is contained in:
Simon Zolin
2019-08-22 15:09:43 +03:00
parent 7d3fe71597
commit c616259e8b
5 changed files with 85 additions and 38 deletions

View File

@@ -30,13 +30,13 @@ var setts RequestFilteringSettings
func purgeCaches() {
if gctx.safebrowsingCache != nil {
gctx.safebrowsingCache.Purge()
gctx.safebrowsingCache.Clear()
}
if gctx.parentalCache != nil {
gctx.parentalCache.Purge()
gctx.parentalCache.Clear()
}
if gctx.safeSearchCache != nil {
gctx.safeSearchCache.Purge()
gctx.safeSearchCache.Clear()
}
}
@@ -51,6 +51,10 @@ func NewForTest(c *Config, filters map[int]string) *Dnsfilter {
setts = RequestFilteringSettings{}
setts.FilteringEnabled = true
if c != nil {
c.SafeBrowsingCacheSize = 1000
c.SafeSearchCacheSize = 1000
c.ParentalCacheSize = 1000
c.CacheTime = 30
setts.SafeSearchEnabled = c.SafeSearchEnabled
setts.SafeBrowsingEnabled = c.SafeBrowsingEnabled
setts.ParentalEnabled = c.ParentalEnabled