当前位置: 首页>>代码示例>>PHP>>正文


PHP cache_get函数代码示例

本文整理汇总了PHP中cache_get函数的典型用法代码示例。如果您正苦于以下问题:PHP cache_get函数的具体用法?PHP cache_get怎么用?PHP cache_get使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cache_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setValue

 /**
  * Set config option value
  *
  * @param string $name
  * @param mixed $value
  * @return mixed
  */
 function setValue($name, $value)
 {
     $option = ConfigOptions::findByName($name);
     if (instance_of($option, 'ConfigOption')) {
         $option->setValue($value);
         $save = $option->save();
         if ($save && !is_error($save)) {
             $cached_values = cache_get('config_values');
             if (is_array($cached_values)) {
                 $cached_values[$name] = $value;
             } else {
                 $cached_values = array($name => $value);
             }
             // if
             cache_set('config_values', $cached_values);
             cache_remove(TABLE_PREFIX . 'config_options_name_' . $name);
             return $value;
         } else {
             return $save;
         }
         // if
     } else {
         return new InvalidParamError('name', $name, "System configuration option '{$name}' does not exist", true);
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:33,代码来源:ConfigOptions.class.php

示例2: enplacify_flickr_get_photo

function enplacify_flickr_get_photo($photo_id)
{
    if (!$GLOBALS['cfg']['flickr_apikey']) {
        return array('ok' => 0, 'error' => 'No Flickr API key');
    }
    $cache_key = "enplacify_flickr_photo_{$photo_id}";
    $cache = cache_get($cache_key);
    if ($cache['ok']) {
        return $cache['data'];
    }
    $url = "http://api.flickr.com/services/rest/?method=flickr.photos.getInfo";
    $url .= "&photo_id={$photo_id}";
    $url .= "&api_key={$GLOBALS['cfg']['flickr_apikey']}";
    $url .= "&format=json&nojsoncallback=1";
    $rsp = http_get($url);
    if (!$rsp['ok']) {
        return $rsp;
    }
    $json = json_decode($rsp['body'], "fuck off php");
    if ($json['stat'] != 'ok') {
        return array('ok' => 0, 'error' => 'Flickr API error');
    }
    $photo = $json['photo'];
    $rsp = array('ok' => 1, 'photo' => $json['photo']);
    cache_set($cache_key, $rsp);
    return $rsp;
}
开发者ID:netcon-source,项目名称:dotspotting,代码行数:27,代码来源:lib_enplacify_flickr.php

示例3: flickr_photos_get_by_id

function flickr_photos_get_by_id($id)
{
    $cache_key = "photo_{$id}";
    $cache = cache_get($cache_key);
    if ($cache['ok']) {
        return $cache['data'];
    }
    $lookup = flickr_photos_lookup_photo($id);
    if (!$lookup) {
        return;
    }
    $user = users_get_by_id($lookup['user_id']);
    $cluster_id = $user['cluster_id'];
    # Temporary – this should never happen
    if (!$cluster_id) {
        return null;
    }
    $enc_id = AddSlashes($id);
    $sql = "SELECT * FROM FlickrPhotos WHERE id='{$enc_id}'";
    $rsp = db_fetch_users($cluster_id, $sql);
    $row = db_single($rsp);
    if ($row) {
        cache_set($cache_key, $row, "cache_locally");
    }
    return $row;
}
开发者ID:nilswalk,项目名称:parallel-flickr,代码行数:26,代码来源:lib_flickr_photos.php

示例4: sheets_lookup_by_fingerprint

function sheets_lookup_by_fingerprint($fingerprint, $user_id = 0)
{
    $cache_key = "sheets_lookup_fingerprint_{$fingerprint}";
    $cache = cache_get($cache_key);
    if ($cache['ok']) {
        return $cache['data'];
    }
    #
    $enc_fingerprint = AddSlashes($fingerprint);
    $sql = "SELECT * FROM SheetsLookup WHERE fingerprint='{$enc_fingerprint}'";
    if ($user_id) {
        $enc_id = AddSlashes($user_id);
        $sql .= " AND user_id='{$enc_id}'";
    }
    $rsp = db_fetch($sql);
    $sheets = array();
    foreach ($rsp['rows'] as $row) {
        $more = array('sheet_user_id' => $row['user_id']);
        if ($sheet = sheets_get_sheet($row['sheet_id'], $user_id, $more)) {
            $sheets[] = $sheet;
        }
    }
    cache_set($cache_key, $sheets);
    return $sheets;
}
开发者ID:netcon-source,项目名称:dotspotting,代码行数:25,代码来源:lib_sheets_lookup.php

示例5: _display_preview

 /**
  * Display preview method
  *
  * NOTE : parent_object & parent_action are used to determine
  */
 function _display_preview($params = [], $template = "")
 {
     $replace = $params['replace'];
     $PARENT_OBJECT = $_REQUEST["parent_object"];
     $PARENT_ACTION = $_REQUEST["parent_action"];
     // If no custom replace given, try to make own
     if (empty($replace)) {
         foreach ((array) $_POST as $k => $v) {
             if (in_array($v, $this->skip_fields)) {
                 continue;
             }
             if ($k != 'category_id') {
                 $replace[$k] = $this->_format_text($v);
             } else {
                 // Try to get category_id based on parent object
                 $categories = cache_get($PARENT_OBJECT . "_categories");
                 $replace['category_id'] = $categories[$v];
             }
         }
     }
     // Try to get template
     if (false !== strpos($_POST['preview_form_action'], "add_comment")) {
         $body = tpl()->parse("comments/preview", $replace);
     } else {
         $stpl_name = $PARENT_OBJECT . "/" . $PARENT_ACTION . "_preview";
         $body = tpl()->_stpl_exists($stpl_name) ? tpl()->parse($stpl_name, $replace) : "";
     }
     // Default body
     if (empty($body)) {
         $body = tpl()->parse(__CLASS__ . "/default", $replace);
     }
     // Process template
     $replace2 = ["template" => $body];
     return common()->show_empty_page(tpl()->parse("preview/main", $replace2), ["title" => t("Preview")]);
 }
开发者ID:yfix,项目名称:yf,代码行数:40,代码来源:yf_preview.class.php

示例6: findAssigneesByObject

 /**
  * Return all users assigned to a specific object
  *
  * @param ProjectObject $object
  * @return array
  */
 function findAssigneesByObject($object)
 {
     $cache_id = 'object_assignments_' . $object->getId();
     $cached_values = cache_get($cache_id);
     if (is_array($cached_values)) {
         if (count($cached_values) > 0) {
             return Users::findByIds($cached_values);
         } else {
             return null;
         }
         // if
     }
     // if
     $users_table = TABLE_PREFIX . 'users';
     $assignments_table = TABLE_PREFIX . 'assignments';
     $cached_values = array();
     $rows = db_execute_all("SELECT {$users_table}.id FROM {$users_table}, {$assignments_table} WHERE {$assignments_table}.object_id = ? AND {$assignments_table}.user_id = {$users_table}.id", $object->getId());
     if (is_foreachable($rows)) {
         foreach ($rows as $row) {
             $cached_values[] = (int) $row['id'];
         }
         // foreach
     }
     // if
     cache_set($cache_id, $cached_values);
     if (count($cached_values) > 0) {
         return Users::findByIds($cached_values);
     } else {
         return null;
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:38,代码来源:Assignments.class.php

示例7: flickr_photos_metadata_load

function flickr_photos_metadata_load(&$photo)
{
    $cache_key = "photos_meta_{$photo['id']}";
    $cache = cache_get($cache_key);
    if ($cache['ok']) {
        return $cache['data'];
    }
    $meta = flickr_photos_metadata_path($photo);
    if (!file_exists($meta)) {
        return array('ok' => 0, 'error' => 'missing meta file');
    }
    $fh = fopen($meta, "r");
    $data = fread($fh, filesize($meta));
    fclose($fh);
    $data = json_decode($data, "as hash");
    # guh... just in case stuff has been double
    # json encoded; this was a by-product of moving
    # over to the http_multi stuff and not realizing
    # what I was doing (20111114/straup)
    if ($data && !is_array($data)) {
        $data = json_decode($data, "as hash");
    }
    if (!$data) {
        return array('ok' => 0, 'error' => 'failed to decode');
    }
    $rsp = array('ok' => 1, 'data' => $data);
    cache_set($cache_key, $rsp);
    return $rsp;
}
开发者ID:nilswalk,项目名称:parallel-flickr,代码行数:29,代码来源:lib_flickr_photos_metadata.php

示例8: getValue

 /**
  * Return value of $name config option for a given project
  *
  * @param string $name
  * @param Project $project
  * @return mixed
  */
 function getValue($name, $project)
 {
     $cache_id = 'project_config_options_' . $project->getId();
     $cached_value = cache_get($cache_id);
     if (is_array($cached_value) && isset($cached_value[$name])) {
         return $cached_value[$name];
     }
     // if
     $option = ConfigOptions::findByName($name, PROJECT_CONFIG_OPTION);
     if (instance_of($option, 'ConfigOption')) {
         $record = db_execute_one('SELECT value FROM ' . TABLE_PREFIX . 'project_config_options WHERE project_id = ? AND name = ?', $project->getId(), $name);
         if (is_array($record) && isset($record['value'])) {
             $value = trim($record['value']) != '' ? unserialize($record['value']) : null;
         } else {
             $value = $option->getValue();
         }
         // if
         if (is_array($cached_value)) {
             $cached_value[$name] = $value;
         } else {
             $cached_value = array($name => $value);
         }
         // if
         cache_set($cache_id, $cached_value);
         return $value;
     } else {
         return new InvalidParamError('name', $name, "Project configuration option '{$name}' does not exist", true);
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:37,代码来源:ProjectConfigOptions.class.php

示例9: resourceExists

/**
 * Checks if a resource exists and returns it if so.
 * 
 * @param string $filename The resource name
 * @param bool $return_url If true returns an URL, else returns true or false depending on if the resource exists
 * @param bool $as_local_path If true returns not URL, but a filepath in local filesystem. Needs $return_url=true.
 * @param bool $nocache If true skips all internal caches and peforms a search now
 * @return string Depending on $return_url returns: (the resource URL or false on error) OR (true or false)
 */
function resourceExists($filename, $return_url = false, $as_local_path = false, $nocache = false)
{
    global $CONFIG;
    $cnc = substr(appendVersion('/'), 1);
    $key = (isSSL() ? "resource_ssl_{$filename}" : "resource_{$filename}") . "_{$cnc}" . ($as_local_path ? "_l" : "");
    if (!$nocache && ($res = cache_get($key)) !== false) {
        return $return_url ? $res : $res != "0";
    }
    $ext = pathinfo($filename, PATHINFO_EXTENSION);
    $reg = "/(^{$ext}\$|^{$ext}\\||\\|{$ext}\$)/i";
    foreach ($CONFIG['resources'] as $conf) {
        if (strpos("|" . $conf['ext'] . "|", "|" . $ext . "|") === false) {
            continue;
        }
        if (!file_exists($conf['path'] . '/' . $filename)) {
            continue;
        }
        if ($as_local_path) {
            return $conf['path'] . '/' . $filename;
        }
        $nc = $conf['append_nc'] ? $cnc : '';
        $res = can_nocache() ? $conf['url'] . $nc . $filename : $conf['url'] . $filename . "?_nc=" . substr($nc, 2, -1);
        if (!$nocache) {
            cache_set($key, $res);
        }
        return $return_url ? $res : true;
    }
    cache_set($key, "0");
    return false;
}
开发者ID:rtoi,项目名称:WebFramework,代码行数:39,代码来源:resources.php

示例10: google_get_mymaps_kml_feed

function google_get_mymaps_kml_feed($url)
{
    $cache_key = "mymaps_kml_" . md5($url);
    $cache = cache_get($cache_key);
    if ($cache['ok']) {
        return $cache['data'];
    }
    $parts = utils_parse_url($url);
    if (!google_is_mymaps_hostname($parts['host'])) {
        return null;
    }
    if ($parts['path'] != '/maps/ms') {
        return null;
    }
    $query = array();
    foreach (explode("&", $parts['query']) as $q) {
        list($key, $value) = explode("=", $q, 2);
        $query[$key] = $value;
    }
    if (!$query['msid']) {
        return null;
    }
    $query['output'] = 'kml';
    $feed_url = "http://{$parts['host']}{$parts['path']}?" . http_build_query($query);
    #
    cache_set($cache_key, $feed_url, "cache locally");
    return $feed_url;
}
开发者ID:netcon-source,项目名称:dotspotting,代码行数:28,代码来源:lib_google.php

示例11: ninesixtyrobots_preprocess_page

/**
 * Add custom PHPTemplate variable into the page template
 */
function ninesixtyrobots_preprocess_page(&$vars)
{
    // Check if the theme is using Twitter.
    $use_twitter = theme_get_setting('use_twitter');
    if (is_null($use_twitter)) {
        $use_twitter = 1;
    }
    // If the theme uses Twitter pull it in and display it in the slogan.
    if ($use_twitter) {
        if ($cache = cache_get('ninesixtyrobots_tweets')) {
            $data = $cache->data;
        } else {
            $query = theme_get_setting('twitter_search_term');
            if (is_null($query)) {
                $query = 'lullabot';
            }
            $query = drupal_urlencode($query);
            $response = drupal_http_request('http://search.twitter.com/search.json?q=' . $query);
            if ($response->code == 200) {
                $data = json_decode($response->data);
                // Set a 5 minute cache on retrieving tweets.
                // Note if this isn't updating on your site *run cron*.
                cache_set('ninesixtyrobots_tweets', $data, 'cache', 300);
            }
        }
        $tweet = $data->results[array_rand($data->results)];
        // Create the actual variable finally.
        $vars['site_slogan'] = check_plain(html_entity_decode($tweet->text));
    }
}
开发者ID:eusholli,项目名称:drupal,代码行数:33,代码来源:template.php

示例12: enplacify_chowhound_get_restaurant

function enplacify_chowhound_get_restaurant($restaurant_id)
{
    $cache_key = "enplacify_chowhound_restaurant_{$restaurant_id}";
    $cache = cache_get($cache_key);
    if ($cache['ok']) {
        return $cache['data'];
    }
    $url = "http://www.chow.com/restaurants/" . urlencode($restaurant_id);
    $headers = array();
    $more = array('follow_redirects' => 1);
    $rsp = http_get($url, $headers, $more);
    if (!$rsp['ok']) {
        return $rsp;
    }
    $vcard_rsp = vcard_parse_html($rsp['body']);
    $graph_rsp = opengraph_parse_html($rsp['body']);
    if (!$vcard_rsp['ok'] && !$graph_rsp['ok']) {
        $rsp = array('ok' => 0, 'error' => 'Failed to parse restaurant');
    } else {
        $restaurant = array_merge($vcard_rsp['vcard'], $graph_rsp['graph']);
        $restaurant['id'] = $restaurant_id;
        $rsp = array('ok' => 1, 'restaurant' => $restaurant);
    }
    cache_set($cache_key, $rsp);
    return $rsp;
}
开发者ID:netcon-source,项目名称:dotspotting,代码行数:26,代码来源:lib_enplacify_chowhound.php

示例13: get

 /**
  * {@inheritdoc}
  */
 public function get($key)
 {
     if ($cache = cache_get($key)) {
         return $cache->data;
     }
     return NULL;
 }
开发者ID:AnnaCaraman,项目名称:ding2,代码行数:10,代码来源:FBSCacheDrupal.php

示例14: enplacify_dopplr_get_place

function enplacify_dopplr_get_place($place_type, $place_id)
{
    $cache_key = "enplacify_dopplr_{$place_type}_{$place_id}";
    $cache = cache_get($cache_key);
    if ($cache['ok']) {
        return $cache['data'];
    }
    $url = "http://dplr.it/" . urlencode($place_type) . "/" . urlencode($place_id);
    $headers = array();
    $more = array('follow_redirects' => 1);
    $rsp = http_get($url, $headers, $more);
    if (!$rsp['ok']) {
        return $rsp;
    }
    # https://github.com/mncaudill/flickr-machinetag-geo/blob/master/src/parsers/dopplr.php
    if (preg_match('#pointLat:(-?\\d.*),#U', $rsp['body'], $m)) {
        $latitude = floatval($m[1]);
    }
    if (preg_match('#pointLng:(-?\\d.*),#U', $rsp['body'], $m)) {
        $longitude = floatval($m[1]);
    }
    if (!$latitude || !$longitude) {
        return array('ok' => 0, 'error' => 'failed to locate lat,lon data');
    }
    if (preg_match('#<title>(.*)\\|#U', $rsp['body'], $m)) {
        $name = trim($m[1]);
    }
    $place = array('latitude' => $latitude, 'longitude' => $longitude, 'url' => $url, 'name' => $name);
    $rsp = array('ok' => 1, 'place' => $place);
    cache_set($cache_key, $rsp);
    return $rsp;
}
开发者ID:netcon-source,项目名称:dotspotting,代码行数:32,代码来源:lib_enplacify_dopplr.php

示例15: show_post_by_category_controller

function show_post_by_category_controller($id)
{
    $category = cache_get('category_' . $id);
    if (!$category) {
        $Posts = many_to_many_model('posts', 'categories', ['t.status' => 'published', 'r.category_id' => $id]);
        $posts = [];
        foreach ($Posts as $Post) {
            $post = one_to_many_model('posts', 'medias', 'left outer', ['t1.id' => $Post['id']]);
            $posts[] = $post->fetch();
        }
        $categories = all_model('categories');
        cache_put('front.category', 'category_' . $id, compact('categories', 'posts'));
        return;
    } else {
        response('200 Ok');
        echo $category;
        return;
    }
    if (!empty($posts)) {
        response('200 Ok');
        view('front.category', compact('posts', 'categories'));
    } else {
        throw new RuntimeException('418');
    }
}
开发者ID:Antoine07,项目名称:pmcv,代码行数:25,代码来源:controllers.php


注:本文中的cache_get函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。