MEMCACHE için dizi ekle

0 Cevap php

İşte benim kod memcache ile "mağaza" mysql sorgularını

$mem = new Memcache;
$mem->connect('127.0.0.1', 11211);

$query = "SELECT * FROM tbl limit 0,20 ";
$key = md5($query);

$get_data = $memcache->get($key);

if($get_data) {
 echo 'Data Pulled From Cache';
} else {
   $res = mysql_fetch_array(mysql_query($query));
   $memcache->set($key, $res, TRUE, 3600); 
}

The problem is that memcache store only the first row returned by query. How to save all 20 rows within one key in memcache ?

0 Cevap