You are here

function media_acquiadam_cache_set in Media: Acquia DAM 7

Cache Acquia DAM asset information locally.

Calling for an already cached asset will update the cache.

Parameters

AcquiaDAM_Assets_AbstractAsset $asset: The Acquia DAM asset to cache.

2 calls to media_acquiadam_cache_set()
media_acquiadam_create_file_from_asset in includes/media_acquiadam.helpers.inc
Create a local file entity for an Acquia DAM asset.
media_acquiadam_get_helper in includes/media_acquiadam.helpers.inc
Asset/folder get helper that can load and store assets to cache.

File

includes/media_acquiadam.cache.inc, line 16
Cache helpers and associated logic.

Code

function media_acquiadam_cache_set(AcquiaDAM_Assets_AbstractAsset $asset) {
  $expiration = !empty($asset['expiration']['dateUnix']) ? $asset['expiration']['dateUnix'] : NULL;
  db_merge('acquiadam_asset_cache')
    ->key([
    'asset_id' => $asset['id'],
  ])
    ->updateFields([
    'changed' => REQUEST_TIME,
    'data' => serialize($asset
      ->toArray()),
    'expiration' => $expiration,
  ])
    ->insertFields([
    'asset_id' => $asset['id'],
    'changed' => REQUEST_TIME,
    'created' => REQUEST_TIME,
    'data' => serialize($asset
      ->toArray()),
    'expiration' => $expiration,
    'type' => $asset
      ->getType(),
  ])
    ->execute();
}