code: public function set(string $key, $data)
      {
          Validation::validateKey($key);
  
          // If the key already exists we need to replace it
          if ($this->get($key) !== false) {
              $this->replace($key, $data);
              return;
          }
  
          // Write the key to the database
          $this->getDatabase()->appendToFile($this->getLineString($key, $data));
  
          // Delete the key from cache
          if ($cache = $this->getConfig()->getCache()) {
              $cache->delete($key);
          }
      }
docs: Set a key in the database.
  
  @param string $key
  @param mixed $data