class_docstr: Use cache for computation
  
  Examples
  --------
  
  >>> cache = Cache(1e9)  # doctest: +SKIP
  
  The cache can be used locally as a context manager around ``compute`` or
  ``get`` calls:
  
  >>> with cache:  # doctest: +SKIP
  ...     result = x.compute()
  
  You can also register a cache globally, so that it works for all
  computations:
  
  >>> cache.register()    # doctest: +SKIP
  >>> cache.unregister()  # doctest: +SKIP
code: def _posttask(self, key, value, dsk, state, id):
      duration = default_timer() - self.starttimes[key]
      deps = state["dependencies"][key]
      if deps:
          duration += max(self.durations.get(k, 0) for k in deps)
      self.durations[key] = duration
      nb = self._nbytes(value) + overhead + sys.getsizeof(key) * 4
      self.cache.put(key, value, cost=duration / nb / 1e9, nbytes=nb)
  
file_path: dask/dask/cache.py
imports: from __future__ import annotations
  import sys
  from numbers import Number
  from timeit import default_timer
  from dask.callbacks import Callback
label_desc: Use image node_id 4 for calling the Cache obj's underlying member method code with example usage: obj._posttask(key, value, dsk, state, id) without return types