You are here

public function BynderApi::updateCachedData in Bynder 8.2

Same name and namespace in other branches
  1. 8.3 src/BynderApi.php \Drupal\bynder\BynderApi::updateCachedData()
  2. 8 src/BynderApi.php \Drupal\bynder\BynderApi::updateCachedData()
  3. 4.0.x src/BynderApi.php \Drupal\bynder\BynderApi::updateCachedData()
1 method overrides BynderApi::updateCachedData()
BynderApiTest::updateCachedData in tests/modules/bynder_test_module/src/BynderApiTest.php
Simulate cache update.

File

src/BynderApi.php, line 309

Class

BynderApi
Bynder API service.

Namespace

Drupal\bynder

Code

public function updateCachedData() {
  $expire = $this->configFactory
    ->get('bynder.settings')
    ->get('cache_lifetime') + $this->time
    ->getRequestTime();
  $items = [];
  foreach (self::CACHED_CALLS as $method => $cid) {
    if ($this->configFactory
      ->get('bynder.settings')
      ->get('debug')) {
      $this->loggerFactory
        ->get('bynder')
        ->debug('Update cache: updating cached data for %method.', [
        '%method' => $method,
      ]);
    }
    $items[$cid] = [
      'data' => call_user_func_array([
        $this
          ->getAssetBankManager(),
        $method,
      ], [])
        ->wait(),
      'expire' => $expire,
    ];
  }
  foreach (static::AUTO_UPDATED_TAGS_QUERIES as $query) {
    $items[self::CID_TAGS . '_' . md5(serialize($query))] = [
      'data' => $this
        ->getAssetBankManager()
        ->getTags($query)
        ->wait(),
      'expire' => $expire,
    ];
  }
  $this->cache
    ->setMultiple($items);
  $this->state
    ->set('bynder_cache_last_update', $this->time
    ->getRequestTime());
}