示例#1
0
 /**
  * clearCache
  *
  * clear memcached key for city
  *
  * @author eloy@wikia
  * @access public
  * @static
  *
  * @param integer $city_id: wiki id in city_list
  *
  * @return boolean status
  */
 public static function clearCache($city_id)
 {
     global $wgMemc, $wgWikicitiesReadOnly;
     if (!self::isUsed()) {
         Wikia::log(__METHOD__, "", "WikiFactory is not used.");
         return false;
     }
     if (!is_numeric($city_id)) {
         return false;
     }
     wfProfileIn(__METHOD__);
     if ($wgWikicitiesReadOnly) {
         Wikia::log(__METHOD__, "", "wgWikicitiesReadOnly mode. Skipping update.");
     } else {
         /**
          * increase number in city_list
          */
         $dbw = self::db(DB_MASTER);
         $dbw->update("city_list", ["city_factory_timestamp" => wfTimestampNow()], ["city_id" => $city_id], __METHOD__);
     }
     /**
      * clear tags cache
      */
     $tags = new WikiFactoryTags($city_id);
     $tags->clearCache();
     /**
      * clear domains cache
      */
     self::clearDomainCache($city_id);
     /**
      * clear variables cache
      */
     $wgMemc->delete("WikiFactory::getCategory:" . $city_id);
     //ugly cat clearing (fb#9937)
     $wgMemc->delete(self::getVarsKey($city_id));
     $city_dbname = self::IDtoDB($city_id);
     $wgMemc->delete(self::getWikiaCacheKey($city_id));
     if (!empty($city_dbname)) {
         $wgMemc->delete(self::getWikiaDBCacheKey($city_dbname));
     }
     wfProfileOut(__METHOD__);
     return true;
 }