You are here

function views_content_cache_update_set in Views content cache 7.3

Same name and namespace in other branches
  1. 6.2 views_content_cache.module \views_content_cache_update_set()

Create one or more update records for the given object.

Parameters

object $object: The object for which the update is occurring. Example: a $node object.

string $object_type: A string identifier that other modules can use to identify the type of object passed to them. Example: 'node'.

int $timestamp: A timestamp to use for the update record. Optional.

Return value

boolean Returns TRUE if one or more update records were written. FALSE if none were written.

10 calls to views_content_cache_update_set()
views_content_cache_comment_delete in ./views_content_cache.module
Implements hook_comment_delete().
views_content_cache_comment_insert in ./views_content_cache.module
Implements hook_comment_insert().
views_content_cache_comment_publish in ./views_content_cache.module
Implements hook_comment_publish().
views_content_cache_comment_unpublish in ./views_content_cache.module
Implements hook_comment_unpublish().
views_content_cache_comment_update in ./views_content_cache.module
Implements hook_comment_update().

... See full list

File

./views_content_cache.module, line 113
Views content cache cache.

Code

function views_content_cache_update_set($object, $object_type, $timestamp = NULL) {
  $update = FALSE;

  // Important to default to time() instead of REQUEST_TIME to avoid race
  // conditions.
  $timestamp = isset($timestamp) ? $timestamp : time();
  if ($cids = views_content_cache_id_generate($object, $object_type)) {
    foreach ($cids as $cid) {
      if (!empty($cid)) {
        $update = TRUE;
        $mapped = views_content_cache_id_record($cid);

        // Ensure that the timestamp is recorded in the table.
        $merge_query = db_merge('views_content_cache')
          ->fields(array(
          'timestamp' => $timestamp,
        ))
          ->key($mapped)
          ->execute();
      }
    }
  }
  return $update;
}