Simple-PHP-Cache icon indicating copy to clipboard operation
Simple-PHP-Cache copied to clipboard

cache class not work in php loops

Open ericfavoni opened this issue 9 years ago • 2 comments

I Put cache class into foreach loops but cache class only add/set one data into cache file. code:

foreach($_POST['audio'] as $audio){ SQL::put("INSERT INTO " . NEWS_FILES . " (news_id, url, type) VALUES (?, ?, ?)", $id, $audio,"audio"); $c->store($id, array( 'action' => array( $id, $video,"audio") )); } cache File:

{"202":{"time":1410452801,"expire":0,"data":{"action":[202,"http://localhost/user/uploads/files/1/thumbs/1/audio/download-kid-photo-c.jpg","audio"]}}}

I have 4 files for id 202 But cache class insert only one files in file. how to fix this?

ericfavoni avatar Sep 12 '14 15:09 ericfavoni

instead of caching data while writing, you should check if data is cached while reading. if cached, read from cache else make query and set cache.

bencagri avatar Sep 26 '14 15:09 bencagri

I have a similar problem. Only the first value is stored. It happens in a AWS instance, but not in my XAMPP. I can clear the cache and write again, but only ONE value.

Any Idea?

mariommoreno avatar Oct 27 '15 12:10 mariommoreno