Ben sorunu olmadan önce kullanmış olduğunuz bir memcache senaryonun biraz aldım, ama yeni sayfada, ben herhangi bir yanıt alamadım.
the memcache is in a function which is included from another page. what I do is put the md5 hash the mysql query and store that as the key for the memcached data. if the key isn't in memcache, then I go, create the data, put it into memcache and return it.
Ben kod oldukça basit olduğunu düşünüyorum. Burada önemli bit (bu çıktıyı yaratmak büyük bir sayfası vardır, bu yüzden ben batırdım nerede olabilir korktuğum gibi düşünüyorum 'iade' önemli olsa, tüm bu gerekmez.
Ben ile işlevini çağırmak
$outList.= outData($getList);
$ GetList bir mysql sorgu nerede
$ OutList fonksiyonu
<?php
@$memcache = new Memcache;
@$memcache->connect("localhost",11211);
function outData($getList)
{
$memVal = @$memcache->get(MD5($getList));
if($memVal=='')
{
$results=mysql_query($getList)or die(mysql_error());
// then I do a bunch of stuff with the data
@$memcache->set(MD5($getList), $memVal, false, 60000);
}
return $memVal;
}
Ben $ memVal oluşturmak için tüm şeyler görüntüleyebilir, ama hata varsa doğrultusunda şüpheli, ama aynı kod sorunları olmadan başka sayfada kullanılır.
Şey bu yanlış görünüyor?