Diyelim ki böyle bir kod olduğunu hayal edelim ...
if (!$data = $cache->load("part1_cache_id")) {
$item_id = $model->getItemId();
ob_start();
echo 'Here is the cached item id: '.$item_id;
$data = ob_get_contents();
ob_end_clean();
$cache->save($data, "part1_cache_id");
}
echo $data;
echo never_cache_function($item_id);
if (!$data_2 = $cache->load("part2_cache_id")) {
ob_start();
echo 'Here is the another cached part of the page...';
$data_2 = ob_get_contents();
ob_end_clean();
$cache->save("part2_cache_id");
}
echo $data_2;
Bildiğim kadarıyla gördüğünüz gibi ben never_cache_function içine $ item_id değişken geçmesi gerekiyor, ama yumruk bölüm (part1_cache_id) önbelleğe ise o zaman $ item_id değer almak için hiçbir yolu yoktur. Ben sadece çözüm görmek - ($ item_id değeri dahil olmak üzere) ilk bölümü tüm verileri serialize; sonra tefrika dizesi önbelleğe ve komut dosyası çalıştırıldığında her onu unserialize ...
Bu gibi bir şey ...
if (!$data = $cache->load("part1_cache_id")) {
$item_id = $model->getItemId();
$data['item_id'] = $item_id;
ob_start();
echo 'Here is the cached item id: '.$item_id;
$data['html'] = ob_get_contents();
ob_end_clean();
$cache->save( serialize($data), "part1_cache_id" );
}
$data = unserialize($data);
echo $data['html']
echo never_cache_function($data['item_id']);
Is there any other ways for doing such trick? I'm looking for the most high performance solution.
Teşekkür ederim
UPDATED And another question is - how to implement such caching into controller without separating page into two templates? Is it possible?
PS: Ben özel önbelleğe uygulama gerçekten ilgileniyorum, Smarty tavsiye etmeyiniz.