If local language's magicwords list is incomplete, try fetching it from the English one
[lhc/web/wiklou.git] / includes / ParserCache.php
1 <?php
2
3 class ParserCache
4 {
5 function getKey( &$article, &$user ) {
6 global $wgDBname;
7 $hash = $user->getPageRenderingHash();
8 $pageid = intval( $article->getID() );
9 $key = "$wgDBname:pcache:idhash:$pageid-$hash";
10 return $key;
11 }
12
13 function get( &$article, &$user ) {
14 global $wgMemc;
15 $fname = "ParserCache::get";
16 wfProfileIn( $fname );
17
18 $hash = $user->getPageRenderingHash();
19 $pageid = intval( $article->getID() );
20 $key = $this->getKey( $article, $user );
21 $value = $wgMemc->get( $key );
22 if ( $value ) {
23 # Delete if article has changed since the cache was made
24 if ( $value->getTouched() != $article->getTouched() ) {
25 $wgMemc->delete( $key );
26 $value = false;
27 }
28 } else {
29 $value = false;
30 }
31
32 wfProfileOut( $fname );
33 return $value;
34 }
35
36 function save( $parserOutput, &$article, &$user ){
37 global $wgMemc;
38 $key = $this->getKey( $article, $user );
39 $parserOutput->setTouched( $article->getTouched() );
40 if( $parserOutput->containsOldMagic() ){
41 $expire = 3600; # 1 hour
42 } else {
43 $expire = 7*86400; # 7 days
44 }
45
46 $wgMemc->set( $key, $parserOutput, $expire );
47 }
48
49 }
50
51
52 ?>