Get the answer associated with *key*. Returns None if no answer is cached for the key. *key*, a ``(dns.name.Name, dns.rdatatype.RdataType, dns.rdataclass.RdataClass)`` tuple whose values are the query name, rdtype, and rdclass respectively. Returns a ``dns.resolver
(self, key: CacheKey)
| 450 | self.next_cleaning = now + self.cleaning_interval |
| 451 | |
| 452 | def get(self, key: CacheKey) -> Answer | None: |
| 453 | """Get the answer associated with *key*. |
| 454 | |
| 455 | Returns None if no answer is cached for the key. |
| 456 | |
| 457 | *key*, a ``(dns.name.Name, dns.rdatatype.RdataType, dns.rdataclass.RdataClass)`` |
| 458 | tuple whose values are the query name, rdtype, and rdclass respectively. |
| 459 | |
| 460 | Returns a ``dns.resolver.Answer`` or ``None``. |
| 461 | """ |
| 462 | |
| 463 | with self.lock: |
| 464 | self._maybe_clean() |
| 465 | v = self.data.get(key) |
| 466 | if v is None or v.expiration <= time.time(): |
| 467 | self.statistics.misses += 1 |
| 468 | return None |
| 469 | self.statistics.hits += 1 |
| 470 | return v |
| 471 | |
| 472 | def put(self, key: CacheKey, value: Answer) -> None: |
| 473 | """Associate key and value in the cache. |