本文整理汇总了PHP中FileCache::GetInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP FileCache::GetInstance方法的具体用法?PHP FileCache::GetInstance怎么用?PHP FileCache::GetInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileCache
的用法示例。
在下文中一共展示了FileCache::GetInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ikit_social_remote_fetch_instagram_feed
/**
* Refresh the Instagram cache
*/
function ikit_social_remote_fetch_instagram_feed()
{
global $g_options;
$instagram_user_id = null;
if (isset($g_options[IKIT_PLUGIN_OPTION_INSTAGRAM_USER_ID])) {
$instagram_user_id = $g_options[IKIT_PLUGIN_OPTION_INSTAGRAM_USER_ID];
}
if ($instagram_user_id != null) {
$curl_list_request = curl_init();
// Fetch recent media for specified user
curl_setopt($curl_list_request, CURLOPT_URL, IKIT_SOCIAL_INSTAGRAM_API_URL . "/users/" . $instagram_user_id . '/media/recent?access_token=' . IKIT_SOCIAL_INSTAGRAM_ACCESS_TOKEN);
curl_setopt($curl_list_request, CURLOPT_RETURNTRANSFER, true);
$curl_list_response = curl_exec($curl_list_request);
curl_close($curl_list_request);
$cache = FileCache::GetInstance(IKIT_SOCIAL_INSTAGRAM_FEED_CACHE_SECS, IKIT_DIR_FILE_CACHE);
$cache->delete(IKIT_SOCIAL_INSTAGRAM_FEED_CACHE_KEY);
// Deletes if older than the expiry time
$cache->cache(IKIT_SOCIAL_INSTAGRAM_FEED_CACHE_KEY, json_decode($curl_list_response));
}
}
示例2: ikit_social_get_facebook_feed_items
/**
* Returns a list of the latest facebook status messages as objects
* safe to call multiple times, cacheing is taken care of,
*/
function ikit_social_get_facebook_feed_items()
{
$cache = FileCache::GetInstance(IKIT_SOCIAL_FACEBOOK_FEED_CACHE_SECS, IKIT_DIR_FILE_CACHE);
$cache_contents = $cache->cache(IKIT_SOCIAL_FACEBOOK_FEED_CACHE_KEY);
if ($cache_contents != null) {
$messages = json_decode($cache->cache(IKIT_SOCIAL_FACEBOOK_FEED_CACHE_KEY));
if (isset($messages->data)) {
return $messages->data;
}
}
return array();
}