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,
);
$items['memcache-test/set/%'] = array(
'title' => 'Set a value with a key',
'page callback' => 'memcache_test_set',
'page arguments' => array(
2,
3,
),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['memcache-test/get/%'] = array(
'title' => 'Get a value from the cache',
'page callback' => 'memcache_test_get',
'page arguments' => array(
2,
),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['memcache-test/wildcard-clear/%'] = array(
'title' => 'Clear the cache with a wildcard',
'page callback' => 'memcache_test_wildcard_flush',
'page arguments' => array(
2,
),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['memcache-test/clear/%'] = array(
'title' => 'Clear the cache with a wildcard',
'page callback' => 'memcache_test_clear',
'page arguments' => array(
2,
),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['memcache-test/clear-cache'] = array(
'title' => 'Clear the cache with a wildcard',
'page callback' => 'memcache_test_clear_cache',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
function memcache_test_lock_acquire() {
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() {
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()';
}
}
function memcache_test_set($key, $value) {
$cache = cache_set($key, $value, 'MemcacheDrupal');
drupal_json_output(cache_get($key, 'MemcacheDrupal'));
}
function memcache_test_get($key) {
$GLOBALS['in_test'] = TRUE;
drupal_json_output(cache_get($key, 'MemcacheDrupal'));
}
function memcache_test_wildcard_flush($key) {
$_SESSION['cache_flush'] = array();
cache_clear_all($key, 'MemcacheDrupal', TRUE);
drupal_json_output($key);
}
function memcache_test_clear($key) {
cache_clear_all($key, 'MemcacheDrupal');
drupal_json_output($key);
}
function memcache_test_clear_cache() {
cache_clear_all(NULL, 'MemcacheDrupal');
drupal_json_output();
}