public function insert($key, $value)
    {
        $this->file->flock(LOCK_SH);
        $this->file->fseek(0, SEEK_END);

        $position = $this->file->ftell();

        if (is_array($value) || is_object($value)) {
            $value = json_encode($value);
        }

        $this->file->flock(LOCK_EX);
        $this->file->fwrite(
            pack('N*', strlen($key)) .
            pack('N*', strlen($value)) .
            $key .
            $value
        );
        $this->file->flock(LOCK_UN);

        return $position;
    }