You are here

function _apdqc_lock_release_fuzzy in Asynchronous Prefetch Database Query Cache 7

Release a lock previously acquired by lock_acquire().

This will release the named lock.

Parameters

string $name: The name of the lock.

Related topics

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

File

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

Code

function _apdqc_lock_release_fuzzy($name) {
  global $locks;
  unset($locks[$name]);

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

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