Use dnspython built-in cache to cache DNS queries for BGPmap

This is equivalent to the previous memcached cache, but much simpler to
deploy (no additional service needed, everything is in process memory)
This commit is contained in:
Baptiste Jonglez 2021-05-10 20:14:43 +02:00 committed by zorun
parent f41056a684
commit 3d90c14bfa
1 changed files with 2 additions and 0 deletions

View File

@ -24,9 +24,11 @@ import socket
import pickle
import xml.parsers.expat
dns_cache = resolver.LRUCache(max_size=10000)
resolv = resolver.Resolver()
resolv.timeout = 0.5
resolv.lifetime = 1
resolv.cache = dns_cache
def resolve(n, q):
return str(resolv.query(n,q)[0])