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.
code: def __setitem__(self, key, value):
      if self.max_size == 0:
          return
      evicted = None
      try:
          i = self.keys_to_indices[key]
      except KeyError:
          if self.max_size == self.__pinned_entry_count:
              raise ValueError(
                  "Cannot increase size of cache where all keys have been pinned."
              )
          entry = Entry(key, value, self.new_entry(key, value))
          if len(self.data) >= self.max_size:
              evicted = self.data[0]
              assert evicted.pins == 0
              del self.keys_to_indices[evicted.key]
              i = 0
              self.data[0] = entry
          else:
              i = len(self.data)
              self.data.append(entry)
          self.keys_to_indices[key] = i
      else:
          entry = self.data[i]
          assert entry.key == key
          entry.value = value
          entry.score = self.on_access(
              entry.key, entry.value, entry.score
          )
  
      self.__balance(i)
  
      if evicted is not None:
          if self.data[0] is not entry:
              assert evicted.score <= self.data[0].score
          self.on_evict(evicted.key, evicted.value, evicted.score)
  
imports: from __future__ import absolute_import, division, print_function
  import attr
label_desc: Use image node_id 5 for calling the GenericCache obj's underlying member method code with example usage: obj.__setitem__(key, value) without return types