class_docstr: Generic supertype for cache implementations.
  
  Defines a dict-like mapping with a maximum size, where as well as mapping
  to a value, each key also maps to a score. When a write would cause the
  dict to exceed its maximum size, it first evicts the existing key with
  the smallest score, then adds the new key to the map.
  
  A key has the following lifecycle:
  
  1. key is written for the first time, the key is given the score
     self.new_entry(key, value)
  2. whenever an existing key is read or written, self.on_access(key, value,
     score) is called. This returns a new score for the key.
  3. When a key is evicted, self.on_evict(key, value, score) is called.
  
  The cache will be in a valid state in all of these cases.
  
  Implementations are expected to implement new_entry and optionally
  on_access and on_evict to implement a specific scoring strategy.
class_docstr_tok: ["Generic","supertype","for","cache","implementations",".","Defines","a","dict-like","mapping","with","a","maximum","size",",","where","as","well","as","mapping","to","a","value",",","each","key","also","maps","to","a","score",".","When","a","write","would","cause","the","dict","to","exceed","its","maximum","size",",","it","first","evicts","the","existing","key","with","the","smallest","score",",","then","adds","the","new","key","to","the","map",".","A","key","has","the","following","lifecycle",":","1.","key","is","written","for","the","first","time",",","the","key","is","given","the","score","self.new_entry","(","key",",","value",")","2.","whenever","an","existing","key","is","read","or","written",",","self.on_access","(","key",",","value",",","score",")","is","called",".","This","returns","a","new","score","for","the","key",".","3",".","When","a","key","is","evicted",",","self.on_evict","(","key",",","value",",","score",")","is","called",".","The","cache","will","be","in","a","valid","state","in","all","of","these","cases",".","Implementations","are","expected","to","implement","new_entry","and","optionally","on_access","and","on_evict","to","implement","a","specific","scoring","strategy","."]
code: def __init__(self, max_size):
      self.max_size = max_size
  
      # Implementation: We store a binary heap of Entry objects in self.data,
      # with the heap property requiring that a parent's score is <= that of
      # its children. keys_to_index then maps keys to their index in the
      # heap. We keep these two in sync automatically - the heap is never
      # reordered without updating the index.
      self.keys_to_indices = {}
      self.data = []
      self.__pinned_entry_count = 0
  
imports: import attr
label_desc: Use image node_id 1 to create a new GenericCache object  with example: obj = GenericCache(max_size)