예제 #1
0
 protected function getXML($force_cache_update)
 {
     $cache_key = $this->getCacheKey();
     $expiry_key = $this->getCacheExpiryKey();
     $expired = $force_cache_update || $this->app->getCacheValue($expiry_key);
     if ($expired === false) {
         // expiry key expired, check for updated content on Tumblr
         $xml = $this->getTumblrXML();
         if ($xml === false) {
             // Tumblr API is down, try long cached value
             $xml = $this->app->getCacheValue($cache_key);
             if ($xml === false) {
                 // Tumblr API is down, but we have no cached value
                 $xml = '';
             }
         } else {
             // update long cache with new Tumblr content
             $this->app->addCacheValue($xml, $cache_key, null, 7200);
         }
         // update expiry cache value
         $this->app->addCacheValue('1', $expiry_key, null, 300);
     } else {
         // expiry key not expired, check for long cached value
         $xml = $this->app->getCacheValue($cache_key);
         if ($xml === false) {
             // long cached version expired or does not exist, check
             // for content on Tumblr
             $xml = $this->getTumblrXML();
             if ($xml === false) {
                 // Tumblr API is down, but we have no cached value
                 $xml = '';
                 $this->app->deleteCacheValue($expiry_key);
             } else {
                 // update long cache with new Tumblr content
                 $this->app->addCacheValue($xml, $cache_key, null, 7200);
             }
         }
     }
     return $xml;
 }