我想让sql查询休眠几秒钟,以验证我的应用程序是否正确缓存了查询结果。
我试图将SLEEP(2)
添加到选择查询中,这导致mysql挂起,直到重新启动为止。
还尝试在实际查询之前添加DO SLEEP(2);
行,这使php抛出“常规错误”异常。
下面是一些示例代码:
$sql = "SELECT ... HUGE LIST OF THINGS";
$result = $myCachedDatabase->query($sql); // Does this actually cache the query result? Or does it perform the query every time?
我想要的是这样的东西:
$sql = "DELAY(5 seconds); SELECT ... HUGE LIST OF THINGS";
$result = $myCachedDatabase->query($sql); // First time it took 5s, second time it was instant - yay it gets cached!
DELAY(5 seconds);
是我要寻找的部分
完成此任务的最佳方法是什么?