You are here

public function DatabaseRawBackend::setMultiple in Supercache 8

Same name and namespace in other branches
  1. 2.0.x src/Cache/DatabaseRawBackend.php \Drupal\supercache\Cache\DatabaseRawBackend::setMultiple()

Store multiple items in the persistent cache.

Parameters

array $items: An array of cache items, keyed by cid. In the form:

$items = array(
  $cid => array(
    // Required.
    'data' => $data,
    // Optional, defaults to CacheRawBackendInterface::CACHE_PERMANENT.
    'expire' => CacheRawBackendInterface::CACHE_PERMANENT,
  ),
);

Overrides CacheRawBackendInterface::setMultiple

1 call to DatabaseRawBackend::setMultiple()
DatabaseRawBackend::set in src/Cache/DatabaseRawBackend.php
Stores data in the persistent cache.

File

src/Cache/DatabaseRawBackend.php, line 177
Contains \Drupal\supercache\Cache\DatabaseRawBackend.

Class

DatabaseRawBackend
Defines a default cache implementation.

Namespace

Drupal\supercache\Cache

Code

public function setMultiple(array $items) {
  $try_again = FALSE;
  try {

    // The bin might not yet exist.
    $this
      ->doSetMultiple($items);
  } catch (\Exception $e) {

    // If there was an exception, try to create the bins.
    if (!($try_again = $this
      ->ensureBinExists())) {

      // If the exception happened for other reason than the missing bin
      // table, propagate the exception.
      throw $e;
    }
  }

  // Now that the bin has been created, try again if necessary.
  if ($try_again) {
    $this
      ->doSetMultiple($items);
  }
}