setMultiple example

public function set($cid$data$expire = Cache::PERMANENT, array $tags = []) {
    foreach ($this->backends as $backend) {
      $backend->set($cid$data$expire$tags);
    }
  }

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

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

  
$this->consistentBackend->set($cid$data$expire$tags);
    $this->markAsOutdated();
    // Don't write the cache tags to the fast backend as any cache tag     // invalidation results in an invalidation of the whole fast backend.     $this->fastBackend->set($cid$data$expire);
  }

  /** * {@inheritdoc} */
  public function setMultiple(array $items) {
    $this->consistentBackend->setMultiple($items);
    $this->markAsOutdated();
    // Don't write the cache tags to the fast backend as any cache tag     // invalidation results in an invalidation of the whole fast backend.     foreach ($items as &$item) {
      unset($item['tags']);
    }
    $this->fastBackend->setMultiple($items);
  }

  /** * {@inheritdoc} */
/** * Sets state flags for language_test module. * * Ensures to correctly update data both in the child site and the test runner * environment. * * @param array $values * The key/value pairs to set in state. */
  protected function stateSet(array $values) {
    // Set the new state values.     $this->container->get('state')->setMultiple($values);
    // Refresh in-memory static state/config caches and static variables.     $this->refreshVariables();
    // Refresh/rewrite language negotiation configuration, in order to pick up     // the manipulations performed by language_test module's info alter hooks.     $this->container->get('language_negotiator')->purgeConfiguration();
  }

  /** * Tests alterations to language types/negotiation info. */
  public function testInfoAlterations() {
    
// Verify that the other collection is not affected.     $this->assertTrue($stores[1]->has('foo'));
    $this->assertEquals($this->objects[2]$stores[1]->get('foo'));
    $stores[1]->delete('foo');
    $this->assertNull($stores[1]->get('foo'));

    // Verify that multiple items can be stored.     $values = [
      'foo' => $this->objects[3],
      'bar' => $this->objects[4],
    ];
    $stores[0]->setMultiple($values);

    // Verify that multiple items can be retrieved.     $result = $stores[0]->getMultiple(['foo', 'bar']);
    foreach ($values as $j => $value) {
      $this->assertEquals($value$result[$j]);
    }

    // Verify that the other collection was not affected.     $this->assertNull($stores[1]->get('foo'));
    $this->assertNull($stores[1]->get('bar'));

    


    #[Route(path: '/api/_action/system-config', name: 'api.action.core.save.system-config', defaults: ['_acl' => ['system_config:update', 'system_config:create', 'system_config:delete']], methods: ['POST'])]     public function saveConfiguration(Request $request): JsonResponse
    {
        $salesChannelId = $request->query->get('salesChannelId');
        if (!\is_string($salesChannelId)) {
            $salesChannelId = null;
        }

        $kvs = $request->request->all();
        $this->systemConfig->setMultiple($kvs$salesChannelId);

        return new JsonResponse(null, Response::HTTP_NO_CONTENT);
    }

    /** * @deprecated tag:v6.6.0 $context param will be required */
    #[Route(path: '/api/_action/system-config/batch', name: 'api.action.core.save.system-config.batch', defaults: ['_acl' => ['system_config:update', 'system_config:create', 'system_config:delete']], methods: ['POST'])]     public function batchSaveConfiguration(Request $request, ?Context $context = null): JsonResponse
    {
        if (!$context) {
            
      $names_to_get = array_keys(array_intersect($cache_keys_map$cache_keys));
      $list = $this->storage->readMultiple($names_to_get);
      // Cache configuration objects that were loaded from the storage, cache       // missing configuration objects as an explicit FALSE.       $items = [];
      foreach ($names_to_get as $name) {
        $data = $list[$name] ?? FALSE;
        $data_to_return[$name] = $data;
        $items[$cache_keys_map[$name]] = ['data' => $data];
      }

      $this->cache->setMultiple($items);
    }

    // Add the configuration objects from the cache to the list.     $cache_keys_inverse_map = array_flip($cache_keys_map);
    foreach ($cached_list as $cache_key => $cache) {
      $name = $cache_keys_inverse_map[$cache_key];
      $data_to_return[$name] = $cache->data;
    }

    // Ensure that only existing configuration objects are returned, filter out     // cached information about missing objects.
$value = EntityTest::create([]);
    // Assert that the entity has at least one violation.     $this->assertNotEmpty($value->validate());
    // Assert that these violations do not prevent it from satisfying the     // requirements of another object.     $requirement = new ContextDefinition('any');
    $context = EntityContext::fromEntity($value);
    $this->assertTrue($requirement->isSatisfiedBy($context));

    // Test with multiple values.     $definition = EntityContextDefinition::create('entity_test');
    $definition->setMultiple();
    $entities = [
      EntityTest::create([]),
      EntityTest::create([]),
    ];
    $context = new Context($definition$entities);
    $this->assertTrue($definition->isSatisfiedBy($context));
  }

  /** * @covers ::__construct */
  
$this->cache[$key] = $value;
    $this->keyValueStore->set($key$value);
  }

  /** * {@inheritdoc} */
  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} */
if (isset($this->skippedTests[__FUNCTION__])) {
            $this->markTestSkipped($this->skippedTests[__FUNCTION__]);
        }

        $cache = $this->createSimpleCache();
        $cache->clear();

        $cache->set('foo', new NotUnserializable());

        $this->assertNull($cache->get('foo'));

        $cache->setMultiple(['foo' => new NotUnserializable()]);

        foreach ($cache->getMultiple(['foo']) as $value) {
        }
        $this->assertNull($value);

        $cache->clear();
    }

    public function testPrune()
    {
        if (isset($this->skippedTests[__FUNCTION__])) {
            

        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);
    }
}

      }
    }

    return $values;
  }

  /** * {@inheritdoc} */
  public function set($key$value) {
    $this->setMultiple([$key => $value]);
  }

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

  
$cache_tags = [
      $this->entityTypeId . '_values',
      'entity_field_info',
    ];
    $items = [];
    foreach ($entities as $id => $entity) {
      $items[$this->buildCacheId($id)] = [
        'data' => $entity,
        'tags' => $cache_tags,
      ];
    }
    $this->cacheBackend->setMultiple($items);
  }

  /** * {@inheritdoc} */
  public function loadUnchanged($id) {
    $entities = [];
    $ids = [$id];

    // The cache invalidation in the parent has the side effect that loading the     // same entity again during the save process (for example in
$this->state->delete('disable_rendered_output_cache_bins');
    }

    $twig_development_mode = (bool) $form_state->getValue('twig_development_mode');
    $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.'));
  }
    if ($cache->serialized) {
      $cache->data = unserialize($cache->data);
    }

    return $cache;
  }

  /** * {@inheritdoc} */
  public function set($cid$data$expire = Cache::PERMANENT, array $tags = []) {
    $this->setMultiple([
      $cid => [
        'data' => $data,
        'expire' => $expire,
        'tags' => $tags,
      ],
    ]);
  }

  /** * {@inheritdoc} */
  
$event = new SystemConfigDomainLoadedEvent($domain$merged$inherit$salesChannelId);
        $this->eventDispatcher->dispatch($event);

        return $event->getConfig();
    }

    /** * @param array<mixed>|bool|float|int|string|null $value */
    public function set(string $key$value, ?string $salesChannelId = null): void
    {
        $this->setMultiple([$key => $value]$salesChannelId);
    }

    /** * @param array<string, array<mixed>|bool|float|int|string|null> $values */
    public function setMultiple(array $values, ?string $salesChannelId = null): void
    {
        $where = $salesChannelId ? 'sales_channel_id = :salesChannelId' : 'sales_channel_id IS NULL';

        $existingIds = $this->connection
            ->fetchAllKeyValue(
                
Home | Imprint | This part of the site doesn't use cookies.