<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set(self, key, val):
 """Sets a value in a key. Args: key (str):
 Key for the value. val: Value to set. Returns: Retrieved value. """

    self._create_file_if_none_exists()
    with open(self.filename, 'r+b') as file_object:
      cache_pickle = pickle.load(file_object)
      cache_pickle[key] = val
      file_object.seek(0)
      pickle.dump(cache_pickle, file_object)