def set(self, key, value):
path = self._getvaluepath(key)<EOL>try:<EOL><INDENT>if path.parent.is_dir():<EOL><INDENT>cache_dir_exists_already = True<EOL><DEDENT>else:<EOL><INDENT>cache_dir_exists_already = self._cachedir.exists()<EOL>path.parent.mkdir(exist_ok=True, parents=True)<EOL><DEDENT><DEDENT>except (IOError, OSError):<EOL><INDENT>self.warn("<STR_LIT>", path=path)<EOL>return<EOL><DEDENT>if not cache_dir_exists_already:<EOL><INDENT>self._ensure_supporting_files()<EOL><DEDENT>try:<EOL><INDENT>f = path.open("<STR_LIT:wb>" if PY2 else "<STR_LIT:w>")<EOL><DEDENT>except (IOError, OSError):<EOL><INDENT>self.warn("<STR_LIT>", path=path)<EOL><DEDENT>else:<EOL><INDENT>with f:<EOL><INDENT>json.dump(value, f, indent=<NUM_LIT:2>, sort_keys=True)<EOL><DEDENT><DEDENT>
save value for the given key.

        :param key: must be a ``/`` separated value. Usually the first
             name is the name of your plugin or your application.
        :param value: must be of any combination of basic
               python types, including nested types
               like e. g. lists of dictionaries.