function ctools_object_cache_test

Determine if another user has a given object cached.

This is very useful for 'locking' objects so that only one user can modify them.

Parameters

$obj: A 128 character or less string to define what kind of object is being stored; primarily this is used to prevent collisions.

$name: The name of the object being removed.

$sid: The session id, allowing someone to use Session API or their own solution; defaults to session_id().

Return value

An object containing the UID and updated date if found; NULL if not.

1 call to ctools_object_cache_test()
page_manager_get_page_cache in page_manager/page_manager.module
Get the cached changes to a given task handler.

File

includes/object-cache.inc, line 140

Code

function ctools_object_cache_test($obj, $name, $sid = NULL) {
    if (!$sid) {
        $sid = session_id();
    }
    return db_query('SELECT s.uid, c.updated FROM {ctools_object_cache} c INNER JOIN {sessions} s ON c.sid = s.sid WHERE s.sid <> :session_id AND c.obj = :obj AND c.name = :name ORDER BY c.updated ASC', array(
        ':session_id' => $sid,
        ':obj' => $obj,
        ':name' => md5($name),
    ))->fetchObject();
}