I want to ask the developer team.
Two parallel processes carry out identical quiry to a database.
Process1 get sql_cache_exists(sql)==false
Process2 get sql_cache_exists(sql)==false
Process1 execute(sql)
Process2 execute(sql)
Process1 sql_cache_store(sql,result)
Process2 sql_cache_store(sql,result) and got an error.
There are three variants of the decision:
1. Find
Code:
function sql_cache_store($zf_query, $zf_result_array) {
global $db;
Add below
Code:
if($this->sql_cache_exists($zf_query)) return true;
2. Same as Nomber 1.
Find
Code:
$sql = "insert into " . TABLE_DB_CACHE . " set cache_entry_name = '" . $zp_cache_name . "',
cache_data = '" . $result_serialize . "',
cache_entry_created = '" . time() . "'";
Add above
Code:
$sql = "select * from " . TABLE_DB_CACHE . " where cache_entry_name = '" . $zp_cache_name . "' LIMIT 1";
$zp_cache_exists = $db->Execute($sql);
if ($zp_cache_exists->RecordCount() > 0) {
return true;
}
3. Find
Code:
$sql = "insert into " . TABLE_DB_CACHE . " set cache_entry_name = '" . $zp_cache_name . "',
Replace by
Code:
$sql = "REPLACE INTO " . TABLE_DB_CACHE . " set cache_entry_name = '" . $zp_cache_name . "',
How you think, what way is better?
Bookmarks