MCPcopy Create free account
hub / github.com/rthalley/dnspython / flush

Method flush

dns/resolver.py:611–633  ·  view source on GitHub ↗

Flush the cache. If *key* is not ``None``, only that item is flushed. Otherwise the entire cache is flushed. *key*, a ``(dns.name.Name, dns.rdatatype.RdataType, dns.rdataclass.RdataClass)`` tuple whose values are the query name, rdtype, and rdclass respectively.

(self, key: CacheKey | None = None)

Source from the content-addressed store, hash-verified

609 self.data[key] = node
610
611 def flush(self, key: CacheKey | None = None) -> None:
612 """Flush the cache.
613
614 If *key* is not ``None``, only that item is flushed. Otherwise the entire cache
615 is flushed.
616
617 *key*, a ``(dns.name.Name, dns.rdatatype.RdataType, dns.rdataclass.RdataClass)``
618 tuple whose values are the query name, rdtype, and rdclass respectively.
619 """
620
621 with self.lock:
622 if key is not None:
623 node = self.data.get(key)
624 if node is not None:
625 node.unlink()
626 del self.data[node.key]
627 else:
628 gnode = self.sentinel.next
629 while gnode != self.sentinel:
630 next = gnode.next
631 gnode.unlink()
632 gnode = next
633 self.data = {}
634
635
636class _Resolution:

Callers

nothing calls this directly

Calls 2

unlinkMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected