[pLog-svn] Problem with cache

Mark Wu markplace at gmail.com
Fri Apr 7 18:46:46 GMT 2006


Hi paul:

Take a look at the same link you give us about "==="

There is a post posted by "sam at liddicott dot com", I guess that's why ===
did the bad job on object comparision.

Mark

> -----Original Message-----
> From: Mark Wu [mailto:markplace at gmail.com] 
> Sent: Saturday, April 08, 2006 2:29 AM
> To: 'plog-svn at devel.lifetype.net'
> Subject: RE: [pLog-svn] Problem with cache
> 
> Hi Paul:
> 
> I just take one hour the check the cache. I don't thinkt the 
> "===" operator did the right job of userInfo, blogInfo and 
> Article category.
> 
> I just print out $dbobject and $tmpobj , and do the 
> "Manually" comparision. Both structures and data are exactly the same.
> 
> So, I don't know why it always return false.
> 
> BTW, I think we had two missing attribue when we map the 
> blogInfo object. I already fix.
> 
> About the articleCategory, userInfo,.... No idea. Need more check.
> 
> Mark
> 
> > -----Original Message-----
> > From: plog-svn-bounces at devel.lifetype.net
> > [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of Paul 
> > Westbrook
> > Sent: Friday, April 07, 2006 4:52 PM
> > To: plog-svn at devel.lifetype.net
> > Subject: Re: [pLog-svn] Problem with cache
> > 
> > Hello,
> >     I was looking in to this problem tonight.  I applied 
> this patch to 
> > model.class.php
> > 
> > Index: class/dao/model.class.php
> > ===================================================================
> > --- class/dao/model.class.php   (revision 3194)
> > +++ class/dao/model.class.php   (working copy)
> > @@ -190,12 +190,29 @@
> >                          $dbObject = $this->mapRow( $row );
> > 
> >                          $this->_cache->setData( $value, $cacheId, 
> > $dbObject );
> > -                       if( $caches ) {
> > -                               foreach( $caches as $cache =>  
> > $getter ) {
> > -                                       $this->_cache->setData 
> > ( $dbObject->$getter(), $cache, $dbObject );
> > -                               }
> > -                       }
> > -               }
> > +
> > +                //
> > +                // Make sure that the data is the same as the
> > original object
> > +                //
> > +                $tmpObj = $this->_cache->getData( $value, 
> $cacheId );
> > +
> > +                // This is relying on php comparing the objects by
> > value,
> > +                // as described in 
> http://php.mirrors.ilisys.com.au/
> > manual/en/language.operators.comparison.php
> > +                if ( $tmpObj === $dbObject ) {
> > +                    if( $caches ) {
> > +                        foreach( $caches as $cache => $getter ) {
> > +                            $this->_cache->setData( $dbObject->
> > $getter(), $cache, $dbObject );
> > +                        }
> > +                    }
> > +                } else {
> > +                  // Remove the entry from the cache, 
> since it is bad
> > +                  // And rely on the answer that we got directly
> > from the
> > +                  // database
> > +                  error_log( "Found bad cached data Id:" . 
> $value .  
> > " cache: " .  $cacheId );
> > +                  $this->_cache->removeData( $value, $cacheId );
> > +                }
> > +
> > +            }
> > 
> >                  return( $dbObject );
> > 
> > 
> > What I was looking for was data that was corrupted when 
> being store to 
> > the cache.  I saw a bunch of log messages that showed where 
> the cached 
> > data was different than the data from the database.  (This 
> differences 
> > could be legitimate.  A different thread could have written to the 
> > cache before a thread had a chance to reread the cache.
> > 
> > I have attached this log.  In the log I see a lot of bloginfo  
> > changes.  (Does the bloginfo db object change for every 
> request?)    
> > But I also see some articles and article_categories.
> > 
> > 
> > --Paul
> > 
> > 
> > 



More information about the pLog-svn mailing list