no the snippet doesn't have an issue, this loop runs only once so
there is no way same object is retrieved more than once. if the loop
seems confusing, you can just remove the  foreach ($sizes as $sz)
{ and ending }.


On May 31, 4:54 am, Bobo <[email protected]> wrote:
> >   foreach ($sizes as $sz) {
> >         $get_result = $memcache->get('inclarr');
> >         if(!empty($get_result)){
> >                 $incl_array = unserialize($get_result);
> >         }
> >         else
> >         {
> >                 $get_result = file_get_contents($path.'/data/incl_'.
> > $sz.'.ser');
> >                 $memcache->set('inclarr', $get_result);
> >                 $incl_array = unserialize($get_result);
> >         }
>
> Sorry I don't know how to solve your problem, but I see something
> silly in this snippet (and the other foreach loops). You're either
> retrieving many times the same object 'inclarr', that could as well be
> retrieved before the loop (once), or you're not retrieving the right
> element from the cache. In the else branch, when you're reading from
> the filesystem, you're differentiatinf between files with the $sz
> variable: the same should be done with the memcache element, I think.
> I'm sorry if I didn't really understood your code and there is a
> perfectly valid reason for what you did.
>
> --
> Andrea Baron
> [email protected]
> [email protected]

Reply via email to