Esempio n. 1
0
 /**
  * Stores a particular key/value pair only if the key doesn't already exist.
  *
  * @param string $key
  *   The key of the data to check and store.
  * @param mixed $value
  *   The data to store.
  *
  * @return bool
  *   TRUE if the data was set, or FALSE if it already existed.
  */
 public function setIfNotExists($key, $value)
 {
     $value = (object) array('owner' => $this->owner, 'data' => $value, 'updated' => (int) $this->requestStack->getMasterRequest()->server->get('REQUEST_TIME'));
     return $this->storage->setWithExpireIfNotExists($key, $value, $this->expire);
 }
Esempio n. 2
0
 /**
  * Stores a particular key/value pair only if the key doesn't already exist.
  *
  * @param string $key
  *   The key of the data to check and store.
  * @param mixed $value
  *   The data to store.
  *
  * @return bool
  *   TRUE if the data was set, or FALSE if it already existed.
  */
 public function setIfNotExists($key, $value)
 {
     $value = (object) array('owner' => $this->owner, 'data' => $value, 'updated' => REQUEST_TIME);
     return $this->storage->setWithExpireIfNotExists($key, $value, $this->expire);
 }