class_docstr: Class that can cache data contained in files
docstr: Load the specified cache within CACHE_PATH in settings
  
  only if *load_policy* is True,
  May use gzip if GZIP_CACHE ins settings is True.
  Sets caching policy according to *caching_policy*.
docstr_tok: ["Load","the","specified","cache","within","CACHE_PATH","in","settings","only","if","*","load_policy","*","is","True",",","May","use","gzip","if","GZIP_CACHE","ins","settings","is","True",".","Sets","caching","policy","according","to","*","caching_policy","*","."]
code: def __init__(self, settings, cache_name, caching_policy, load_policy):
      """Load the specified cache within CACHE_PATH in settings
  
      only if *load_policy* is True,
      May use gzip if GZIP_CACHE ins settings is True.
      Sets caching policy according to *caching_policy*.
      """
      self.settings = settings
      self._cache_path = os.path.join(
          self.settings["CACHE_PATH"], cache_name
      )
      self._cache_data_policy = caching_policy
      if self.settings["GZIP_CACHE"]:
          import gzip
  
          self._cache_open = gzip.open
      else:
          self._cache_open = open
      if load_policy:
          try:
              with self._cache_open(self._cache_path, "rb") as fhandle:
                  self._cache = pickle.load(fhandle)
          except (OSError, UnicodeDecodeError) as err:
              logger.debug(
                  "Cannot load cache %s (this is normal on first "
                  "run). Proceeding with empty cache.\n%s",
                  self._cache_path,
                  err,
              )
              self._cache = {}
          except pickle.PickleError as err:
              logger.warning(
                  "Cannot unpickle cache %s, cache may be using "
                  "an incompatible protocol (see pelican "
                  "caching docs). "
                  "Proceeding with empty cache.\n%s",
                  self._cache_path,
                  err,
              )
              self._cache = {}
      else:
          self._cache = {}
  
file_path: pelican/pelican/cache.py
imports: import hashlib
  import logging
  import os
  import pickle
  from pelican.utils import mkdir_p
label_desc: Use image node_id 1 to create a new FileDataCacher object  with example: obj = FileDataCacher(settings, cache_name, caching_policy, load_policy)