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 $value = $wgMemc->get( $key );
23 # Delete if article has changed since the cache was made
24 $touched = $article->getTouched();
25 if ( $value->getTouched() != $touched ||
$touched > $wgCacheEpoch ) {
26 $wgMemc->delete( $key );
33 wfProfileOut( $fname );
37 function save( $parserOutput, &$article, &$user ){
39 $key = $this->getKey( $article, $user );
40 $touched = $article->getTouched();
41 $parserOutput->setTouched( $touched );
42 $parserOutput->mText
.= "\n<!-- Saved in parser cache with key $key and timestamp $touched -->\n";
44 if( $parserOutput->containsOldMagic() ){
45 $expire = 3600; # 1 hour
47 $expire = 7*86400; # 7 days
50 $wgMemc->set( $key, $parserOutput, $expire );