I have the following testcode.

Now its a very smal array, but in realtime very large.

How can i update only the values from key 1 direct in the APC FOO?

$test = array(
    array(
        'name' => 'Mike',
        'lastname' => 'Last',
    ),
    array(
        'name' => 'test',
        'lastname' => 'testlast',
    ),
    array(
        'name' => 'anothertest',
        'lastname' => 'anothertestlast',
    ),
);
apc_store('foo', $test);
print_r(apc_fetch('foo'));
有帮助吗?

解决方案

I don't think you can alter the variable directly in the cache. My best guess would be to write a function which gets the data from the cache, alters it, and stores it back in the cache. Maybe something like:

function apc_update_array($cacheKey, $arrayKey, $array)
{
    $data = apc_fetch($cacheKey);
    $data[$arrayKey] = $array;
    apc_store($cacheKey, $data);
}

With that function you could just run the following code to get it done.

apc_update_array(
    'foo',
    1,
    array(
        'name' => 'differenttest',
        'lastname' => 'differenttestlast',
    )
);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top