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 __init__(self, cache, *args, **kwargs):
      try:
          import cachey
      except ImportError as ex:
          raise ImportError(
              'Cache requires cachey, "{ex}" problem '
              "importing".format(ex=str(ex))
          ) from ex
      self._nbytes = cachey.nbytes
      if isinstance(cache, Number):
          cache = cachey.Cache(cache, *args, **kwargs)
      else:
          assert not args and not kwargs
      self.cache = cache
      self.starttimes = dict()
  
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 1 to create a new Cache object from inherited base classes: Callback with example: obj = Cache(cache)