memcache_test.module in Memcache API and Integration 6
File
tests/memcache_test.module
View source
<?php
function memcache_test_menu() {
$items['memcache-test/lock-acquire'] = array(
'title' => 'Lock acquire',
'page callback' => 'memcache_test_lock_acquire',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['memcache-test/lock-exit'] = array(
'title' => 'Lock acquire then exit',
'page callback' => 'memcache_test_lock_exit',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
function memcache_test_lock_acquire() {
dmemcache_key(FALSE, FALSE, TRUE);
$GLOBALS['drupal_test_info']['test_run_id'] = arg(2);
if (lock_acquire('memcache_test_lock_acquire')) {
lock_release('memcache_test_lock_acquire');
return 'TRUE: Lock successfully acquired in memcache_test_lock_acquire()';
}
else {
return 'FALSE: Lock not acquired in memcache_test_lock_acquire()';
}
}
function memcache_test_lock_exit() {
dmemcache_key(FALSE, FALSE, TRUE);
$GLOBALS['drupal_test_info']['test_run_id'] = arg(2);
if (lock_acquire('memcache_test_lock_exit', 900)) {
echo 'TRUE: Lock successfully acquired in memcache_test_lock_exit()';
exit;
}
else {
return 'FALSE: Lock not acquired in memcache_test_lock_exit()';
}
}