保存数据

@inner
@param {Storage} storage 存储数据
@param {Object} data 数据
514636
function setData(storage, data) {
    var core = storage.core;
    core.setItem(storage.id, JSON.stringify(data));
}
46229
public void setStorage(java.util.Collection<ValidStorageOptions> storage) {
        if (storage == null) {
            this.storage = null;
            return;
        }

        this.storage = new java.util.ArrayList<ValidStorageOptions>(storage);
    }
229493
public function setStorage(Storage $storage = null)
    {
        if ($this->storage !== $storage) {
            $this->storage = $storage;
        }

        return $this;
    }
1012364
function stash(storage, storageKey, key, value) {

        // get the squirrel storage object.
        var store = window.JSON.parse(storage.getItem(storageKey));

        // if it doesn't exist, create an empty object.
        if (store === null) {

            store = {};

        }

        // if a value isn't specified.
        if (isUndefined(value) || value === null) {

            // return the store value if the store value exists; otherwise, null.
            return !isUndefined(store[key]) ? store[key] : null;

        }

        // if a value is specified.
        // create an append object literal.
        var append = {};

        // add the new value to the object that we'll append to the store object.
        append[key] = value;

        // extend the squirrel store object.
        // in ES6 this can be shortened to just $.extend(store, {[key]: value}), as there would be no need
        // to create a temporary storage object.
        $.extend(store, append);

        // re-session the squirrel store again.
        storage.setItem(storageKey, window.JSON.stringify(store));

        // return the value.
        return value;

    }
322528
function(key) {
            var s = Storage.storage();
            if (s == null) {
                return false;
            }
            return _.isUndefined(s[key]) == false;
        }
851468
function saveData(data) {
    console.log('saving data', data);
    if (options.cacheKeys) {
      cachedKeys = Object.keys(data);
    }
    if (file === false) {
      return Promise.resolve();
    } else {
      return writeFile(file, JSON.stringify(data, null, 2));
    }
  }
263128
function store(obj, elem, key)
{
  Array.isArray(obj) ? obj.push(elem) : (obj[key] = elem);
}
1297058
function savePersistentData()
    {
        $this->HTTP->setSessionVariable( $this->StorageName . $this->MetaDataName, $this->MetaData );
        $this->HTTP->setSessionVariable( $this->StorageName . $this->VariableListName, $this->VariableList );
    }
932496
function write(file, data) {
  writeFileSync(file, data);

  console.log(
    `✓ ${relative(__dirname + "/../", file)} (${bytes(statSync(file).size)})`
  );
}
1031060
function storeOptions() {
    var showTomster = this.checked;

    chrome.storage.sync.set({
      options: { showTomster: showTomster }
    }, function optionsSaved() {
      console.log("saved!");
    });
  }
943913
public static function append($storage, $data = [])
    {
        if (!is_array($storage) || !is_array($data)) {
            throw new ArrayStorageException('Invalid parameters specified');
        }
        foreach ($data as $setting => $value) {
            if (array_key_exists($setting, $storage) &&
                is_array($storage[$setting]) &&
                is_array($value)
            ) {
                $storage[$setting] = self::append($storage[$setting], $value);
            } else {
                $storage[$setting] = $value;
            }
        }
        return $storage;
    }
794707
function _initStorage(options) {
        var self = this;
        var dbInfo = {};
        if (options) {
            for (var i in options) {
                dbInfo[i] = options[i];
            }
        }

        dbInfo.keyPrefix = dbInfo.name + '/';

        self._dbInfo = dbInfo;
        return Promise.resolve();
    }
305479
public void saveStoreFile() {
    JSONArray array = new JSONArray(this.keys.values());

    try {
      if (this.storeFile.exists()) {
        this.storeFile.delete();
        this.storeFile.createNewFile();
      }

      BufferedOutputStream bos = new BufferedOutputStream(
          new FileOutputStream(this.storeFile)
      );
      OutputStreamWriter osw = new OutputStreamWriter(bos);
      osw.write(array.toString());
      osw.close();
    } catch (FileNotFoundException e) {
      log.error("Could not find JSONKeystore file!");
      log.debug(e.toString());
    } catch (IOException e) {
      log.error("Could not create new JSONKeystore file!");
      log.debug(e.toString());
    }
  }
284400
function(callback) {

            // first check if storage define a 'keys()' function. if it does, use it
            if (typeof this._storage.keys === "function") {
                var keys = this._storage.keys();
                for (var i = 0; i < keys.length; ++i) {
                    callback(keys[i]);
                }
            }

            // if not supported try to use object.keys
            else if (typeof Object === "function" && Object.keys) {
                var keys = Object.keys(this._storage);
                for (var i = 0; i < keys.length; ++i) {
                    callback(keys[i]);
                }
            }

            // if not supported try to use iteration via length
            else if (this._storage.length !== undefined && typeof this._storage.key === "function") {

                // first build keys array, so this function will be delete-safe (eg if callback remove keys it won't cause problems due to index change)
                var keys = [];
                for (var i = 0, len = this._storage.length; i < len; ++i) {
                    keys.push(this._storage.key(i));
                }
                // now actually iterate keys
                for (var i = 0; i < keys.length; ++i) {
                    callback(keys[i]);
                }
            }

            // if both methods above didn't work, iterate on all keys in storage class hoping for the best..
            else {
                for (var storageKey in this._storage) {
                    callback(storageKey);
                }
            }
        }
1128943
function reuse() {
      if(!storage[storageKey] && post.collection('parent') && post.collection('parent')[storageKey]){
        $contentDomNode.html(post.collection('parent')[storageKey]);
        $contentDomNode.attr('data-div-placeholder-content', 'true');
        saveData();
      }
    }
891643
public void save(String storageName) {
        //store the objects on storage
        storageEngine.saveObject("modelParameters", modelParameters);
        storageEngine.saveObject("trainingParameters", trainingParameters);

        //rename the storage
        storageEngine.rename(storageName);

        //reload the model parameters, necessary for the maps to point to the new location
        modelParameters = (MP) storageEngine.loadObject("modelParameters", ModelParameters.class);
    }
1374620
function save(storage, name, value) {
      try {
        var key = propsPrefix + name;
        if (value == null) value = '';
        storage[key] = value;
      } catch (err) {
        console.log('Cannot access local/session storage:', err);
      }
    }