APC缓存不迭代存储在缓存中的变量

APC caching not iterating variable stored in caching

当我使用 APC 缓存技术时,它第一次访问数据库,下次它应该进入 apc 缓存 do.but 当我想从 apc 缓存中迭代相同的变量时,它不会工作。我是 APC 缓存的新手,是否还有更多要检查的 APC 缓存。

<?php
include 'connection.php';
$sql="select * from table";
     if (apc_exists($sql)) {
        $array1=apc_fetch(sql);
        echo 'from cache';
    }
    else{
$countsql3 = mysqli_query($mysqli, $sql) or die("Cannot Get Pname Info: (".mysql_error().")");

while($row = mysqli_fetch_array($countsql3)) {$array1[] = $row;}
        print_r($array1);
        apc_store($sql,$array1,86400);
    }   
foreach(array1 as $array){}
?>

如果有条件但 foreach 循环没有被执行,它将被缓存,是否需要为变量缓存做任何不同的事情

将密钥作为字符串传递:

apc_store('sql', $array1, 86400);

还有这里:

if (apc_exists('sql')) {
    $array1 = apc_fetch('sql');
    echo 'from cache';
}