}
}
+ /**
+ * Get the last touched timestamp
+ */
+ function getTouched() {
+ $dbr =& wfGetDB( DB_SLAVE );
+ $touched = $dbr->selectField( 'page', 'page_touched',
+ array(
+ 'page_namespace' => $this->getNamespace(),
+ 'page_title' => $this->getDBkey()
+ ), __METHOD__
+ );
+ return $touched;
+ }
+
+ /**
+ * Get a cached value from a global cache that is invalidated when this page changes
+ * @param string $key the key
+ * @param callback $callback A callback function which generates the value on cache miss
+ */
+ function getRelatedCache( $memc, $key, $expiry, $callback, $params = array() ) {
+ $touched = $this->getTouched();
+ $cacheEntry = $memc->get( $key );
+ if ( $cacheEntry ) {
+ if ( $cacheEntry['touched'] >= $touched ) {
+ return $cacheEntry['value'];
+ } else {
+ wfDebug( __METHOD__.": $key expired\n" );
+ }
+ } else {
+ wfDebug( __METHOD__.": $key not found\n" );
+ }
+ $value = call_user_func_array( $callback, $params );
+ $cacheEntry = array(
+ 'value' => $value,
+ 'touched' => $touched
+ );
+ $memc->set( $key, $cacheEntry, $expiry );
+ return $value;
+ }
+
function trackbackURL() {
global $wgTitle, $wgScriptPath, $wgServer;