我喜欢使用memcached存储定期更新sql语句,然后批量执行它们可能每隔30秒就这样开启..我怎么能以编程方式编写代码呢?
我尝试了以下功能,但我完全迷失了
function search_click($search_id)
{
if (MEMCACHE === true) {
$key = __FUNCTION__.date("Y-m-d H:i",time());
//. strtotime(date("Ymdhi", time()));
$memcache_obj = new Memcache;
$memcache_obj->connect('localhost', 11211);
$sql = $memcache_obj->get($key);
$sql.= " UPDATE LOW_PRIORITY search_si
SET count=count+1
WHERE
search_id='" . mysql_real_escape_string($search_id) . "' ; ";
$memcache_obj->set($key,$sql);// repopulate the cache
$res = mysql_query($sql) or die(mysql_error());
}
}