You are here

function _apdqc_lock_release_all in Asynchronous Prefetch Database Query Cache 7

Same name in this branch
  1. 7 apdqc.lock.apc.inc \_apdqc_lock_release_all()
  2. 7 apdqc.lock.db.inc \_apdqc_lock_release_all()
  3. 7 apdqc.lock.memcache_storage.inc \_apdqc_lock_release_all()
  4. 7 apdqc.lock.memcache.inc \_apdqc_lock_release_all()
  5. 7 apdqc.lock.redis.inc \_apdqc_lock_release_all()

Release all previously acquired locks.

Parameters

string $lock_id: Unique id for all locks acquired during this request.

Related topics

1 call to _apdqc_lock_release_all()
apdqc.lock.inc in ./apdqc.lock.inc
A database-mediated implementation of a locking mechanism.
1 string reference to '_apdqc_lock_release_all'
apdqc.lock.inc in ./apdqc.lock.inc
A database-mediated implementation of a locking mechanism.

File

./apdqc.lock.db.inc, line 358
A database-mediated implementation of a locking mechanism.

Code

function _apdqc_lock_release_all($lock_id = NULL) {
  global $locks;
  $locks = array();
  if (empty($lock_id)) {
    $lock_id = _lock_id();
  }

  // Build query.
  $query = \Database::getConnection()
    ->prefixTables("\n    DELETE FROM {" . db_escape_table('semaphore') . "}\n    WHERE value = '" . apdqc_escape_string($lock_id) . "'\n  ");

  // Run Query.
  $results = apdqc_query(array(
    'semaphore',
  ), array(
    $lock_id,
  ), $query, array(
    'get_affected_rows' => TRUE,
    'async' => TRUE,
  ));
  if (is_string($results) && $results === 'NO DB') {
    db_delete('semaphore')
      ->condition('value', $lock_id)
      ->execute();
  }
}