1--TEST-- 2Session lock 3--SKIPIF-- 4<?php 5include dirname(__FILE__) . "/skipif.inc"; 6if (!Memcached::HAVE_SESSION) print "skip"; 7 8if (PHP_VERSION_ID < 70100) print "skip"; 9?> 10--INI-- 11memcached.sess_locking = true 12memcached.sess_lock_wait_min = 500 13memcached.sess_lock_wait_max = 1000 14memcached.sess_lock_retries = 3 15memcached.sess_prefix = "memc.test." 16 17# Turn off binary protocol while the test matrix has older versions of 18# libmemcached for which the extension warns of a broken touch command. 19memcached.sess_binary_protocol = Off 20 21session.save_handler = memcached 22 23--FILE-- 24<?php 25 26include dirname (__FILE__) . '/config.inc'; 27 28$m = new Memcached(); 29$m->addServer(MEMC_SERVER_HOST, MEMC_SERVER_PORT); 30 31ob_start(); 32ini_set ('session.save_path', MEMC_SERVER_HOST . ':' . MEMC_SERVER_PORT); 33 34session_start(); 35$session_id = session_id(); 36 37$_SESSION["test"] = "hello"; 38session_write_close(); 39 40session_start(); 41var_dump ($m->get ('memc.test.' . session_id())); 42var_dump ($m->get ('memc.test.lock.' . session_id())); 43session_write_close(); 44var_dump ($m->get ('memc.test.lock.' . session_id())); 45 46// Test lock min / max 47$m->set ('memc.test.lock.' . $session_id, '1'); 48 49$time_start = microtime(true); 50session_start(); 51$time = microtime(true) - $time_start; 52 53if (round ($time, 1) != 2.5) { 54 echo "Waited longer than expected: $time" . PHP_EOL; 55} 56echo "OK"; 57 58--EXPECTF-- 59string(17) "test|s:5:"hello";" 60string(1) "1" 61bool(false) 62 63Warning: session_start(): Unable to clear session lock record in %s on line %d 64 65Warning: session_start(): Failed to read session data: memcached (path: 127.0.0.1:11211) in %s on line %d 66OK 67