deleteMultiple example

public function setMultiple(array $data) {
    foreach ($data as $key => $value) {
      $this->cache[$key] = $value;
    }
    $this->keyValueStore->setMultiple($data);
  }

  /** * {@inheritdoc} */
  public function delete($key) {
    $this->deleteMultiple([$key]);
  }

  /** * {@inheritdoc} */
  public function deleteMultiple(array $keys) {
    foreach ($keys as $key) {
      $this->cache[$key] = NULL;
    }
    $this->keyValueStore->deleteMultiple($keys);
  }

  

  public function setMultipleWithExpire(array $data$expire) {
    foreach ($data as $key => $value) {
      $this->setWithExpire($key$value$expire);
    }
  }

  /** * {@inheritdoc} */
  public function deleteMultiple(array $keys) {
    parent::deleteMultiple($keys);
  }

  /** * Defines the schema for the key_value_expire table. */
  public static function schemaDefinition() {
    return [
      'description' => 'Generic key/value storage table with an expiration.',
      'fields' => [
        'collection' => [
          'description' => 'A named collection of key and value pairs.',
          


  /** * {@inheritdoc} */
  public function deleteLastInstalledDefinition($entity_type_id) {
    $this->keyValueFactory->get('entity.definitions.installed')->delete($entity_type_id . '.entity_type');
    // Clean up field storage definitions as well. Even if the entity type     // isn't currently fieldable, there might be legacy definitions or an     // empty array stored from when it was.     $this->keyValueFactory->get('entity.definitions.installed')->delete($entity_type_id . '.field_storage_definitions');
    $this->cacheBackend->deleteMultiple(['entity_type_definitions.installed', $entity_type_id . '.field_storage_definitions.installed']);
    $this->entityTypeDefinitions = NULL;
    return $this;
  }

  /** * {@inheritdoc} */
  public function getLastInstalledFieldStorageDefinitions($entity_type_id) {
    if ($cache = $this->cacheBackend->get($entity_type_id . '.field_storage_definitions.installed')) {
      return $cache->data;
    }
    
public function delete($cid) {
    foreach ($this->backends as $backend) {
      $backend->delete($cid);
    }
  }

  /** * {@inheritdoc} */
  public function deleteMultiple(array $cids) {
    foreach ($this->backends as $backend) {
      $backend->deleteMultiple($cids);
    }
  }

  /** * {@inheritdoc} */
  public function deleteAll() {
    foreach ($this->backends as $backend) {
      $backend->deleteAll();
    }
  }

  
    $backend->set('test1', 1);
    $backend->set('test2', 3);
    $backend->set('test3', 5);
    $backend->set('test4', 7);
    $backend->set('test5', 11);
    $backend->set('test6', 13);
    $backend->set('test7', 17);

    $backend->delete('test1');
    // Nonexistent key should not cause an error.     $backend->delete('test23');
    $backend->deleteMultiple([
      'test3',
      'test5',
      'test7',
      // Nonexistent key should not cause an error.       'test19',
      // Nonexistent key should not cause an error.       'test21',
    ]);

    // Test if expected keys have been deleted.     $this->assertFalse($backend->get('test1'), "Cache id test1 deleted.");
    
return $this->findByPrefixCache[$cache_key];
  }

  /** * {@inheritdoc} */
  public function deleteAll($prefix = '') {
    // If the cache was the first to be deleted, another process might start     // rebuilding the cache before the storage is renamed.     $names = $this->storage->listAll($prefix);
    if ($this->storage->deleteAll($prefix)) {
      $this->cache->deleteMultiple($this->getCacheKeys($names));
      return TRUE;
    }
    return FALSE;
  }

  /** * Clears the static list cache. */
  public function resetListCache() {
    $this->findByPrefixCache = [];
  }

  
    // Ensure that an item with the same name exists in the other collection.     $stores[1]->set('foo', $this->objects[5]);

    // Not using assertSame(), since the order is not defined for getAll().     $this->assertEquals($values$stores[0]->getAll());

    // Verify that all items in the other collection are different.     $result = $stores[1]->getAll();
    $this->assertEquals(['foo' => $this->objects[5]]$result);

    // Verify that multiple items can be deleted.     $stores[0]->deleteMultiple(array_keys($values));
    $this->assertNull($stores[0]->get('foo'));
    $this->assertNull($stores[0]->get('bar'));
    $this->assertEmpty($stores[0]->getMultiple(['foo', 'bar']));
    // Verify that the item in the other collection still exists.     $this->assertEquals($this->objects[5]$stores[1]->get('foo'));

    // Test that setWithExpireIfNotExists() succeeds only the first time.     $key = $this->randomMachineName();
    for ($i = 0; $i <= 1; $i++) {
      // setWithExpireIfNotExists() should be TRUE the first time (when $i is       // 0) and FALSE the second time (when $i is 1).
$twig_development_previous = $this->state->getMultiple(['twig_debug', 'twig_cache_disable']);
    $twig_development = [
      'twig_debug' => (bool) $form_state->getValue('twig_debug'),
      'twig_cache_disable' => (bool) $form_state->getValue('twig_cache_disable'),
    ];
    if ($twig_development_mode) {
      $invalidate_container = $twig_development_previous !== $twig_development;
      $this->state->setMultiple($twig_development);
    }
    else {
      $invalidate_container = TRUE;
      $this->state->deleteMultiple(array_keys($twig_development));
    }

    if ($invalidate_container || $disable_rendered_output_cache_bins_previous !== $disable_rendered_output_cache_bins) {
      $this->kernel->invalidateContainer();
    }

    $this->messenger()->addStatus($this->t('The settings have been saved.'));
  }

}
    // Ensure that an item with the same name exists in the other collection.     $stores[1]->set('foo', $this->objects[5]);

    // Not using assertSame(), since the order is not defined for getAll().     $this->assertEquals($values$stores[0]->getAll());

    // Verify that all items in the other collection are different.     $result = $stores[1]->getAll();
    $this->assertEquals(['foo' => $this->objects[5]]$result);

    // Verify that multiple items can be deleted.     $stores[0]->deleteMultiple(array_keys($values));
    $this->assertNull($stores[0]->get('foo'));
    $this->assertNull($stores[0]->get('bar'));
    $this->assertEmpty($stores[0]->getMultiple(['foo', 'bar']));
    // Verify that deleting no items does not cause an error.     $stores[0]->deleteMultiple([]);
    // Verify that the item in the other collection still exists.     $this->assertEquals($this->objects[5]$stores[1]->get('foo'));

  }

  /** * Tests expected behavior for non-existing keys. */

        return $this->pool->has($id);
    }

    protected function doClear(string $namespace): bool
    {
        return $this->pool->clear();
    }

    protected function doDelete(array $ids): bool
    {
        return $this->pool->deleteMultiple($ids);
    }

    protected function doSave(array $values, int $lifetime): array|bool
    {
        return $this->pool->setMultiple($values, 0 === $lifetime ? null : $lifetime);
    }
}
public function setMultiple(array $data) {
    foreach ($data as $key => $value) {
      $this->cache[$key] = $value;
    }
    $this->keyValueStore->setMultiple($data);
  }

  /** * {@inheritdoc} */
  public function delete($key) {
    $this->deleteMultiple([$key]);
  }

  /** * {@inheritdoc} */
  public function deleteMultiple(array $keys) {
    foreach ($keys as $key) {
      unset($this->cache[$key]);
    }
    $this->keyValueStore->deleteMultiple($keys);
  }

  

  public function resetCache(array $ids = NULL) {
    if ($ids) {
      parent::resetCache($ids);
      if ($this->entityType->isPersistentlyCacheable()) {
        $cids = [];
        foreach ($ids as $id) {
          unset($this->latestRevisionIds[$id]);
          $cids[] = $this->buildCacheId($id);
        }
        $this->cacheBackend->deleteMultiple($cids);
      }
    }
    else {
      parent::resetCache();
      if ($this->entityType->isPersistentlyCacheable()) {
        Cache::invalidateTags([$this->entityTypeId . '_values']);
      }
      $this->latestRevisionIds = [];
    }
  }

}

  public function setMultiple(array $data) {
    foreach ($data as $key => $value) {
      $this->set($key$value);
    }
  }

  /** * {@inheritdoc} */
  public function delete($key) {
    $this->deleteMultiple([$key]);
  }

}
    // invalidation results in an invalidation of the whole fast backend.     foreach ($items as &$item) {
      unset($item['tags']);
    }
    $this->fastBackend->setMultiple($items);
  }

  /** * {@inheritdoc} */
  public function delete($cid) {
    $this->consistentBackend->deleteMultiple([$cid]);
    $this->markAsOutdated();
  }

  /** * {@inheritdoc} */
  public function deleteMultiple(array $cids) {
    $this->consistentBackend->deleteMultiple($cids);
    $this->markAsOutdated();
  }

  
      // unnecessary loops within the method.       $query->values(array_values($fields));
    }

    $query->execute();
  }

  /** * {@inheritdoc} */
  public function delete($cid) {
    $this->deleteMultiple([$cid]);
  }

  /** * {@inheritdoc} */
  public function deleteMultiple(array $cids) {
    $cids = array_values(array_map([$this, 'normalizeCid']$cids));
    try {
      // Delete in chunks when a large array is passed.       foreach (array_chunk($cids, 1000) as $cids_chunk) {
        $this->connection->delete($this->bin)
          
Home | Imprint | This part of the site doesn't use cookies.