public function run($request)
 {
     if (!Director::is_cli()) {
         exit("Invalid\n");
     }
     $cacheName = $request->getVar('cache');
     $key = $request->getVar('key');
     if (!strlen($cacheName) || !strlen($key)) {
         exit("Cache and key required\n");
     }
     $cache = SimpleCache::get_cache($cacheName);
     if ($cache) {
         $data = $cache->get($key);
         if ($data) {
             var_export($data);
         }
     }
 }
function display_tencent($args = '')
{
    $default = array('username' => 'Weibo_ID', 'number' => '5', 'time' => '3600');
    $r = wp_parse_args($args, $default);
    extract($r);
    $path = dirname(dirname(__FILE__)) . '/wordpress-tencent-microblog/xxx';
    $cache = new SimpleCache();
    $cache->cache_path = $path;
    $cache->cache_time = 43200;
    date_default_timezone_set('PRC');
    if ($data = $cache->get_cache(date('Y-m-d-H'))) {
        $list = json_decode($data);
    } else {
        $uinfo = OpenSDK_Tencent_Weibo::call('statuses/broadcast_timeline', array('reqnum' => $number, 'type' => '1', 'contenttype' => '0'));
        $cache->set_cache(date('Y-m-d-H'), json_encode($uinfo));
    }
    $decodedArray = $list;
    echo '<ul style="list-style-type:none;">';
    foreach ($decodedArray['data']['info'] as $value) {
        echo '<li><div class="microblog"><a href="http://t.qq.com/' . $value['nick'] . '" rel="external nofollow" title="来自 腾讯微博" target="_blank" style="padding-right:3px;"><img class="microblog-ico"  alt="腾讯微博" src="' . WP_PLUGIN_URL . '/wordpress-tencent-microblog/txwb.png" /></a><span class="microblog-content">' . str_replace('&#160;', ' ', $value['origtext']) . '</span>  <span class="microblog-from" style="font-size:smaller;">-' . date("Y/m/d", $value['timestamp']) . ' 来自 ' . $value['from'] . '-</span></div></li>';
    }
    echo '</ul>';
}
 protected function getCache($name)
 {
     $cache = SimpleCache::get_cache($name);
     return $cache;
 }
}
// Remove base folders from the URL if webroot is hosted in a subfolder
if (substr(strtolower($url), 0, strlen(BASE_URL)) == strtolower(BASE_URL)) {
    $url = substr($url, strlen(BASE_URL));
}
if (defined('USE_PROXY') && USE_PROXY) {
    if (defined('PROXY_CONFIG_FILE')) {
        include_once BASE_PATH . '/' . PROXY_CONFIG_FILE;
    }
    $publisher = null;
    if (defined('PROXY_PUBLISHER')) {
        $publisher = SimpleCache::get_cache(PROXY_PUBLISHER);
    }
    $dynamic = null;
    if (defined('PROXY_DYNAMIC_PUBLISHER')) {
        $dynamic = SimpleCache::get_cache(PROXY_DYNAMIC_PUBLISHER);
    }
    $cookies = defined('PROXY_BYPASS_COOKIES') ? explode(',', PROXY_BYPASS_COOKIES) : array();
    $url_config = isset($PROXY_CACHE_URLS) ? $PROXY_CACHE_URLS : null;
    $blacklist = isset($PROXY_CACHE_BLACKLIST) ? $PROXY_CACHE_BLACKLIST : array();
    $proxyclass = defined('PROXY_CLASS') ? PROXY_CLASS : 'FrontendProxy';
    $proxy = new $proxyclass($publisher, $dynamic, $url_config, $cookies);
    $proxy->setCacheGetVars(defined('CACHE_ALLOW_GET_VARS') && CACHE_ALLOW_GET_VARS)->setIgnoreGetVars(defined('CACHE_IGNORE_GET_VARS') && CACHE_IGNORE_GET_VARS)->setBlacklist($blacklist);
    if (isset($PROXY_CACHE_REMAP)) {
        $proxy->setRemapHosts($PROXY_CACHE_REMAP);
    }
    if (defined('PROXY_CONTENT_REWRITER')) {
        $proxy->setContentRewriter(PROXY_CONTENT_REWRITER);
    }
    $host = $_SERVER['HTTP_HOST'];
    $trimFunc = defined('PROXY_TRIM_FUNC') ? PROXY_TRIM_FUNC : 'trim';
 /**
  * Clears the dynamic cached data for a particular data object
  * @param DataObject $object
  */
 public function clearDynamicCacheFor(DataObject $object)
 {
     $dynamicCache = SimpleCache::get_cache('DynamicPublisherCache');
     if ($dynamicCache) {
         $clearUrls = array($object->Link());
         if ($object->hasMethod('pagesAffectedByChanges')) {
             $affectedUrls = $object->pagesAffectedByChanges();
             if (count($affectedUrls)) {
                 foreach ($affectedUrls as $afUrl) {
                     $clearUrls[] = $afUrl;
                 }
             }
         }
         $clearUrls = array_unique($clearUrls);
         $baseUrl = $object->SiteID ? $object->Site()->getUrl() : Director::absoluteBaseURL();
         foreach ($clearUrls as $absolute) {
             if (strpos($absolute, '://') === false) {
                 $absolute = $baseUrl . '/' . trim($absolute, '/');
             }
             $parts = parse_url($absolute);
             $host = $parts['host'];
             $path = '/index';
             $path = isset($parts['path']) && $parts['path'] != '/' ? $parts['path'] : $path;
             $key = trim($parts['host'] . $path, '/');
             $dynamicCache->delete($key);
         }
     }
 }