mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-01-14 02:25:52 +01:00
Improve caching
This commit is contained in:
parent
4c934fc816
commit
1527d6ed5e
@ -226,7 +226,7 @@ func (plugin *PluginCacheResponse) Eval(pluginsState *PluginsState, msg *dns.Msg
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
ttl := getMinTTL(msg, 60, 86400, 60)
|
ttl := getMinTTL(msg, pluginsState.cacheMinTTL, pluginsState.cacheMaxTTL, pluginsState.cacheNegTTL)
|
||||||
cachedResponse := CachedResponse{
|
cachedResponse := CachedResponse{
|
||||||
expiration: time.Now().Add(ttl),
|
expiration: time.Now().Add(ttl),
|
||||||
msg: *msg,
|
msg: *msg,
|
||||||
@ -234,7 +234,7 @@ func (plugin *PluginCacheResponse) Eval(pluginsState *PluginsState, msg *dns.Msg
|
|||||||
plugin.cachedResponses.Lock()
|
plugin.cachedResponses.Lock()
|
||||||
defer plugin.cachedResponses.Unlock()
|
defer plugin.cachedResponses.Unlock()
|
||||||
if plugin.cachedResponses.cache == nil {
|
if plugin.cachedResponses.cache == nil {
|
||||||
plugin.cachedResponses.cache, err = lru.NewARC(1000)
|
plugin.cachedResponses.cache, err = lru.NewARC(pluginsState.cacheSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -276,7 +276,9 @@ func (plugin *PluginCache) Eval(pluginsState *PluginsState, msg *dns.Msg) error
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
synth := cached.msg
|
synth := cached.msg
|
||||||
synth.MsgHdr = msg.MsgHdr
|
synth.Id = msg.Id
|
||||||
|
synth.Response = true
|
||||||
|
synth.Compress = true
|
||||||
synth.Question = msg.Question
|
synth.Question = msg.Question
|
||||||
pluginsState.synthResponse = &synth
|
pluginsState.synthResponse = &synth
|
||||||
pluginsState.action = PluginsActionSynth
|
pluginsState.action = PluginsActionSynth
|
||||||
|
Loading…
Reference in New Issue
Block a user