5 function getKey( &$article, &$user ) {
7 $hash = $user->getPageRenderingHash();
8 $pageid = intval( $article->getID() );
9 $key = "$wgDBname:pcache:idhash:$pageid-$hash";
13 function get( &$article, &$user ) {
14 global $wgMemc, $wgCacheEpoch;
15 $fname = "ParserCache::get";
16 wfProfileIn( $fname );
18 $hash = $user->getPageRenderingHash();
19 $pageid = intval( $article->getID() );
20 $key = $this->getKey( $article, $user );
21 wfDebug( "Trying parser cache $key\n" );
22 $value = $wgMemc->get( $key );
24 wfDebug( "Found.\n" );
25 # Delete if article has changed since the cache was made
26 $touched = $article->getTouched();
27 $cacheTime = $value->getCacheTime();
28 if ( $value->getCacheTime() <= $touched ||
$cacheTime < $wgCacheEpoch ) {
29 wfDebug( "Key expired, touched $touched, epoch $wgCacheEpoch, cached $cacheTime\n" );
30 $wgMemc->delete( $key );
37 wfProfileOut( $fname );
41 function save( $parserOutput, &$article, &$user ){
43 $key = $this->getKey( $article, $user );
44 $now = wfTimestampNow();
45 $parserOutput->setCacheTime( $now );
46 $parserOutput->mText
.= "\n<!-- Saved in parser cache with key $key and timestamp $now -->\n";
48 if( $parserOutput->containsOldMagic() ){
49 $expire = 3600; # 1 hour
51 $expire = 86400; # 1 day
54 $wgMemc->set( $key, $parserOutput, $expire );