class_docstr: A dictionary that maintains up to :maxsize: key-value-expiration tuples until their expiration_time
class_docstr_tok: ["A","dictionary","that","maintains","up","to",":","maxsize",":","key-value-expiration","tuples","until","their","expiration_time"]
docstr: Return the entry with earliest expiration or None if there isn't any
docstr_tok: ["Return","the","entry","with","earliest","expiration","or","None","if","there","is","n't","any"]
code: def top(
      self,
  ) -> Tuple[
      Optional[KeyType], Optional[ValueWithExpiration[ValueType]]
  ]:
      """Return the entry with earliest expiration or None if there isn't any"""
      self._remove_outdated()
      if self.data:
          # skip leftover "ghost" entries until first real entry
          while (
              self.key_to_heap.get(self.expiration_heap[ROOT].key)
              != self.expiration_heap[ROOT]
          ):
              heapq.heappop(self.expiration_heap)
          top_key = self.expiration_heap[ROOT].key
          return top_key, self.data[top_key]
      return None, None
  
imports: from __future__ import annotations
  import heapq
  import time
  from contextlib import contextmanager
  from dataclasses import dataclass
  from typing import Dict, Generic, Iterator, List, Optional, Tuple, TypeVar
label_desc: Use image node_id 6 for calling the TimedStorage obj's underlying member method code with example usage: obj.top() and returns: None,  None, top_key,  self