remove() public method

If the store does not contain the key, this method returns false. Any integer or string value is accepted as key. If any other type is passed for the key, an {@link InvalidKeyException} is thrown. You should make sure that you only pass valid keys to the store. If the backend of the store cannot be written, a {@link WriteException} is thrown. You should always handle this exception in your code: php try { $store->remove($key); } catch (WriteException $e) { write failed }
public remove ( integer | string $key ) : boolean
$key integer | string The key to remove.
return boolean Returns `true` if a key was removed from the store.
コード例 #1
0
 private function syncBindingsForKey($key)
 {
     if (count($this->bindingsByKey[$key]) > 0) {
         $this->store->set('b:' . $key, $this->bindingsByKey[$key]);
     } else {
         unset($this->bindingsByKey[$key]);
         $this->store->remove('b:' . $key);
     }
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 protected function removeBindingsWithTypeName($typeName)
 {
     if (!isset($this->keysByTypeName[$typeName])) {
         return;
     }
     $key = $this->keysByTypeName[$typeName];
     if (!isset($this->bindingsByKey[$key])) {
         // no initialize, since we're removing this anyway
         $this->loadBindingsForKey($key, false);
     }
     foreach ($this->bindingsByKey[$key] as $binding) {
         unset($this->keysByUuid[$binding->getUuid()->toString()]);
     }
     unset($this->bindingsByKey[$key]);
     $this->store->remove('b:' . $key);
     $this->store->set('::keysByUuid', $this->keysByUuid);
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function purge($path)
 {
     $this->store->remove($path);
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function remove($key)
 {
     $this->store->remove($key);
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 protected function removeBinding($id)
 {
     unset($this->bindings[$id]);
     $this->store->remove($id);
 }