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


PHP Cache::retrieve方法代码示例

本文整理汇总了PHP中Cache::retrieve方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::retrieve方法的具体用法?PHP Cache::retrieve怎么用?PHP Cache::retrieve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cache的用法示例。


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

示例1: clearCache

 public function clearCache()
 {
     $cache = new \Cache(['path' => __DIR__ . '/../../../../frontend/runtime/redirectCache/', 'name' => 'default', 'extension' => '.cache']);
     if ($cache->retrieve($this->from)) {
         $cache->erase($this->from);
     }
 }
开发者ID:tolik505,项目名称:bl,代码行数:7,代码来源:Redirects.php

示例2: osc_latestTweets

function osc_latestTweets($num = 5)
{
    require_once osc_lib_path() . 'osclass/classes/Cache.php';
    $cache = new Cache('admin-twitter', 900);
    if ($cache->check()) {
        return $cache->retrieve();
    }
    $list = array();
    $content = osc_file_get_contents('https://twitter.com/statuses/user_timeline/osclass.rss');
    if ($content) {
        $xml = simplexml_load_string($content);
        if (isset($xml->error)) {
            return $list;
        }
        $count = 0;
        foreach ($xml->channel->item as $item) {
            $list[] = array('link' => strval($item->link), 'title' => strval($item->title), 'pubDate' => strval($item->pubDate));
            $count++;
            if ($count == $num) {
                break;
            }
        }
    }
    $cache->store($list);
    return $list;
}
开发者ID:semul,项目名称:Osclass,代码行数:26,代码来源:feeds.php

示例3: __construct

 public function __construct($id = null, $enable_hook = true)
 {
     $this->class_name = get_class($this);
     if (!Object::$db) {
         Object::$db = Db::getInstance();
     }
     self::$is_cache_enabled = defined('OBJECT_CACHE_ENABLE') ? OBJECT_CACHE_ENABLE : false;
     if (isset($id) && Validate::isUnsignedId($id)) {
         $cache_id = $this->class_name . self::CACHE_PREFIX_MODEL . (int) $id;
         if (!Cache::isStored($cache_id)) {
             $sql = new DbQuery();
             $sql->from($this->def['table'], 'a');
             $sql->where('a.' . $this->def['primary'] . '=' . (int) $id);
             if ($object_datas = Object::$db->getRow($sql)) {
                 Cache::store($cache_id, $object_datas);
             }
         } else {
             $object_datas = Cache::retrieve($cache_id);
         }
         if ($object_datas) {
             $this->id = (int) $id;
             foreach ($object_datas as $key => $value) {
                 if (array_key_exists($key, $this)) {
                     $this->{$key} = $value;
                 }
             }
         }
         if ($enable_hook && method_exists($this, 'extraConstruct')) {
             $this->extraConstruct();
         }
     }
 }
开发者ID:liu33851861,项目名称:CZD_Yaf_Extension,代码行数:32,代码来源:Object.php

示例4: load

    /**
     * Load ObjectModel
     * @param $id
     * @param $id_lang
     * @param $entity ObjectModel
     * @param $entity_defs
     * @param $id_shop
     * @param $should_cache_objects
     * @throws PrestaShopDatabaseException
     */
    public function load($id, $id_lang, $entity, $entity_defs, $id_shop, $should_cache_objects)
    {
        // Load object from database if object id is present
        $cache_id = 'objectmodel_' . $entity_defs['classname'] . '_' . (int) $id . '_' . (int) $id_shop . '_' . (int) $id_lang;
        if (!$should_cache_objects || !Cache::isStored($cache_id)) {
            $sql = new DbQuery();
            $sql->from($entity_defs['table'], 'a');
            $sql->where('a.`' . bqSQL($entity_defs['primary']) . '` = ' . (int) $id);
            // Get lang informations
            if ($id_lang && isset($entity_defs['multilang']) && $entity_defs['multilang']) {
                $sql->leftJoin($entity_defs['table'] . '_lang', 'b', 'a.`' . bqSQL($entity_defs['primary']) . '` = b.`' . bqSQL($entity_defs['primary']) . '` AND b.`id_lang` = ' . (int) $id_lang);
                if ($id_shop && !empty($entity_defs['multilang_shop'])) {
                    $sql->where('b.`id_shop` = ' . (int) $id_shop);
                }
            }
            // Get shop informations
            if (Shop::isTableAssociated($entity_defs['table'])) {
                $sql->leftJoin($entity_defs['table'] . '_shop', 'c', 'a.`' . bqSQL($entity_defs['primary']) . '` = c.`' . bqSQL($entity_defs['primary']) . '` AND c.`id_shop` = ' . (int) $id_shop);
            }
            if ($object_datas = Db::getInstance()->getRow($sql)) {
                if (!$id_lang && isset($entity_defs['multilang']) && $entity_defs['multilang']) {
                    $sql = 'SELECT *
							FROM `' . bqSQL(_DB_PREFIX_ . $entity_defs['table']) . '_lang`
							WHERE `' . bqSQL($entity_defs['primary']) . '` = ' . (int) $id . ($id_shop && $entity->isLangMultishop() ? ' AND `id_shop` = ' . (int) $id_shop : '');
                    if ($object_datas_lang = Db::getInstance()->executeS($sql)) {
                        foreach ($object_datas_lang as $row) {
                            foreach ($row as $key => $value) {
                                if ($key != $entity_defs['primary'] && array_key_exists($key, $entity)) {
                                    if (!isset($object_datas[$key]) || !is_array($object_datas[$key])) {
                                        $object_datas[$key] = array();
                                    }
                                    $object_datas[$key][$row['id_lang']] = $value;
                                }
                            }
                        }
                    }
                }
                $entity->id = (int) $id;
                foreach ($object_datas as $key => $value) {
                    if (array_key_exists($key, $entity)) {
                        $entity->{$key} = $value;
                    } else {
                        unset($object_datas[$key]);
                    }
                }
                if ($should_cache_objects) {
                    Cache::store($cache_id, $object_datas);
                }
            }
        } else {
            $object_datas = Cache::retrieve($cache_id);
            if ($object_datas) {
                $entity->id = (int) $id;
                foreach ($object_datas as $key => $value) {
                    $entity->{$key} = $value;
                }
            }
        }
    }
开发者ID:jpodracky,项目名称:dogs,代码行数:69,代码来源:Adapter_EntityMapper.php

示例5: isTaxInUse

 /**
  * @param int $id_tax
  * @return bool
  */
 public static function isTaxInUse($id_tax)
 {
     $cache_id = 'TaxRule::isTaxInUse_' . (int) $id_tax;
     if (!Cache::isStored($cache_id)) {
         $result = (int) Db::getInstance()->getValue('SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'tax_rule` WHERE `id_tax` = ' . (int) $id_tax);
         Cache::store($cache_id, $result);
         return $result;
     }
     return Cache::retrieve($cache_id);
 }
开发者ID:jpodracky,项目名称:dogs,代码行数:14,代码来源:TaxRule.php

示例6: getZones

    /**
     * Get all available geographical zones
     *
     * @param bool $active
     * @return array Zones
     */
    public static function getZones($active = false)
    {
        $cache_id = 'Zone::getZones_' . (bool) $active;
        if (!Cache::isStored($cache_id)) {
            $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
				SELECT *
				FROM `' . _DB_PREFIX_ . 'zone`
				' . ($active ? 'WHERE active = 1' : '') . '
				ORDER BY `name` ASC
			');
            Cache::store($cache_id, $result);
        }
        return Cache::retrieve($cache_id);
    }
开发者ID:IngenioContenidoDigital,项目名称:americana,代码行数:20,代码来源:Zone.php

示例7: getOrderStates

    /**
     * Get all available order states
     *
     * @param integer $id_lang Language id for state name
     * @return array Order states
     */
    public static function getOrderStates($id_lang)
    {
        $cache_id = 'OrderState::getOrderStates_' . (int) $id_lang;
        if (!Cache::isStored($cache_id)) {
            $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
			SELECT *
			FROM `' . _DB_PREFIX_ . 'order_state` os
			LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = ' . (int) $id_lang . ')
			WHERE deleted = 0
			ORDER BY `name` ASC');
            Cache::store($cache_id, $result);
        }
        return Cache::retrieve($cache_id);
    }
开发者ID:dev-lav,项目名称:htdocs,代码行数:20,代码来源:OrderState.php

示例8: getTaxCalculator

 /**
  * Return the tax calculator associated to this address.
  *
  * @return TaxCalculator
  */
 public function getTaxCalculator()
 {
     static $tax_enabled = null;
     if (isset($this->tax_calculator)) {
         return $this->tax_calculator;
     }
     if ($tax_enabled === null) {
         $tax_enabled = Configuration::get('PS_TAX');
     }
     if (!$tax_enabled) {
         return new TaxCalculator(array());
     }
     $taxes = array();
     $postcode = 0;
     if (!empty($this->address->postcode)) {
         $postcode = $this->address->postcode;
     }
     $context = Context::getContext();
     $cache_id = (int) $this->address->id_country . '-' . (int) $this->address->id_state . '-' . $postcode . '-' . (int) $this->type;
     if (!Cache::isStored($cache_id)) {
         $rows = Db::getInstance()->executeS('
             SELECT tr.*
             FROM `' . _DB_PREFIX_ . 'tax_rule` tr
             JOIN `' . _DB_PREFIX_ . 'tax_rules_group` trg ON (tr.`id_tax_rules_group` = trg.`id_tax_rules_group`)
             WHERE trg.`active` = 1
             AND tr.`id_country` = ' . (int) $this->address->id_country . '
             AND tr.`id_tax_rules_group` = ' . (int) $this->type . '
             AND tr.`id_state` IN (0, ' . (int) $this->address->id_state . ')
             AND (tr.`id_group` = ' . (int) Customer::getDefaultGroupId((int) $context->customer->id) . ' OR tr.`id_group` = 0)
             AND (\'' . pSQL($postcode) . '\' BETWEEN tr.`zipcode_from` AND tr.`zipcode_to` OR (tr.`zipcode_to` = 0 AND tr.`zipcode_from` IN(0, \'' . pSQL($postcode) . '\')))
             ORDER BY tr.`zipcode_from` DESC, tr.`zipcode_to` DESC, tr.`id_state` DESC, tr.`id_country` DESC');
         $behavior = 0;
         $first_row = true;
         foreach ($rows as $row) {
             $tax = new Tax((int) $row['id_tax']);
             $taxes[] = $tax;
             // the applied behavior correspond to the most specific rules
             if ($first_row) {
                 $behavior = $row['behavior'];
                 $first_row = false;
             }
             if ($row['behavior'] == 0) {
                 break;
             }
         }
         Cache::store($cache_id, new TaxCalculator($taxes, $behavior));
     }
     return Cache::retrieve($cache_id);
 }
开发者ID:banquito,项目名称:taxrulesbycustomergroup,代码行数:54,代码来源:TaxRulesTaxManager.php

示例9: getIdByName

    /**
     * Get a state id with its name
     *
     * @param string $id_state Country ID
     * @return int state id
     */
    public static function getIdByName($state)
    {
        if (empty($state)) {
            return false;
        }
        $cache_id = 'State::getIdByName_' . pSQL($state);
        if (!Cache::isStored($cache_id)) {
            $result = (int) Db::getInstance()->getValue('
				SELECT `id_state`
				FROM `' . _DB_PREFIX_ . 'state`
				WHERE `name` = \'' . pSQL($state) . '\'
			');
            Cache::store($cache_id, $result);
            return $result;
        }
        return Cache::retrieve($cache_id);
    }
开发者ID:jpodracky,项目名称:dogs,代码行数:23,代码来源:State.php

示例10: osc_listNews

/**
 * This functions retrieves a news list from http://osclass.org. It uses the Cache services to speed up the process.
 */
function osc_listNews()
{
    require_once LIB_PATH . 'osclass/classes/Cache.php';
    $cache = new Cache('admin-blog_news', 900);
    if ($cache->check()) {
        return $cache->retrieve();
    } else {
        $list = array();
        $content = osc_file_get_contents('http://osclass.org/feed/');
        if ($content) {
            $xml = simplexml_load_string($content);
            foreach ($xml->channel->item as $item) {
                $list[] = array('link' => strval($item->link), 'title' => strval($item->title), 'pubDate' => strval($item->pubDate));
            }
        }
        $cache->store($list);
    }
    return $list;
}
开发者ID:acharei,项目名称:OSClass,代码行数:22,代码来源:feeds.php

示例11: listcloud_CloudDump

function listcloud_CloudDump()
{
    require_once LIB_PATH . 'osclass/classes/Cache.php';
    $cache = new Cache('listcloud_feeds', 900);
    if ($cache->check()) {
        return $cache->retrieve();
    } else {
        $list = array();
        $content = osc_file_get_contents(osc_base_url() . 'index.php?page=search&sFeed=rss');
        if ($content) {
            $xml = simplexml_load_string($content);
            foreach ($xml->channel->item as $item) {
                $list[] = array('title' => strval($item->title));
            }
        }
        $cache->store($list);
    }
    return $list;
}
开发者ID:fear-otaku,项目名称:oc-listcloud,代码行数:19,代码来源:index.php

示例12: getAddresses

    /**
     * Return customer addresses
     * Override method with default Prestashop Method, To don't show the Receiver address to Custommer/ Sender
     * @param integer $id_lang Language ID
     * @param bool $ship2myid_flag flag to show the address
     * @return array Addresses
     */
    public function getAddresses($id_lang, $ship2myid_flag = true)
    {
        $share_order = (bool) Context::getContext()->shop->getGroup()->share_order;
        $cache_id = 'Customer::getAddresses' . (int) $this->id . '-' . (int) $id_lang . '-' . $share_order;
        if (!Cache::isStored($cache_id)) {
            $sql = 'SELECT DISTINCT a.*, cl.`name` AS country, s.name AS state, s.iso_code AS state_iso
					FROM `' . _DB_PREFIX_ . 'address` a
					LEFT JOIN `' . _DB_PREFIX_ . 'country` c ON (a.`id_country` = c.`id_country`)
					LEFT JOIN `' . _DB_PREFIX_ . 'country_lang` cl ON (c.`id_country` = cl.`id_country`)
					LEFT JOIN `' . _DB_PREFIX_ . 'state` s ON (s.`id_state` = a.`id_state`)
					' . ($share_order ? '' : Shop::addSqlAssociation('country', 'c')) . ' 
					WHERE `id_lang` = ' . (int) $id_lang . ' AND `id_customer` = ' . (int) $this->id . ' AND a.`deleted` = 0';
            //echo $ship2myid_flag.'hii';
            if ($ship2myid_flag) {
                $sql .= ' AND ( ( LOWER(alias ) NOT LIKE "ship2myid-%") AND (LOWER(alias) NOT LIKE "shiptomyid-%" ) ) ';
            }
            $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
            Cache::store($cache_id, $result);
        }
        return Cache::retrieve($cache_id);
    }
开发者ID:ac3gam3r,项目名称:Maxokraft,代码行数:28,代码来源:Customer.php

示例13: hg_facebook_user_tiles

function hg_facebook_user_tiles()
{
    $c = new Cache();
    $c->setCachePath(HG_DIR . '/sdk/cache/');
    $c->seed = NONCE_SALT;
    $c->eraseExpired();
    $_template = '<div id="faces-wrap">
		<div class="faces">%s</div>
	</div>';
    $_template_item = sprintf('<img src="%s/sdk/cache/%%s.jpg">', get_bloginfo('template_directory'));
    $output = "";
    if ($c->isCached('attending')) {
        $attending = $c->retrieve('attending');
    } else {
        $facebook = new Facebook(array('appId' => FACEBOOK_EVENT_APP_ID, 'secret' => FACEBOOK_EVENT_APP_KEY));
        $attending = array();
        $access_token = $facebook->getAccessToken();
        $params = array('access_token' => $access_token);
        $objs = $facebook->api(FACEBOOK_EVENT_APP_ID . '/events', 'GET', $params);
        foreach ($objs['data'] as $data) {
            $objs2 = $facebook->api($data['id'] . '/invited', 'GET', $params);
            foreach ($objs2['data'] as $attendee) {
                if ($attendee['rsvp_status'] == 'attending' || $attendee['rsvp_status'] == 'unsure') {
                    if (!is_file(get_stylesheet_directory() . '/sdk/cache/' . $attendee['id'] . '.jpg')) {
                        file_put_contents(get_stylesheet_directory() . '/sdk/cache/' . $attendee['id'] . '.jpg', file_get_contents(get_bloginfo('template_directory') . '/sdk/timthumb.php?src=http://graph.facebook.com/' . $attendee['id'] . '/picture?type=large&w=75&h=75'));
                    }
                    $attending[] = $attendee['id'];
                }
            }
        }
        $c->store('attending', shuffle($attending), 60 * 60 * 24 * 7);
    }
    if (!is_array($attending) || sizeof($attending) < 10) {
        return "";
    }
    foreach ($attending as $id) {
        $output .= sprintf($_template_item, $id);
    }
    return sprintf($_template, $output);
}
开发者ID:nathanwaters,项目名称:HackagongWP,代码行数:40,代码来源:functions.php

示例14: getTotalPaid

 /**
  * Amounts of payments
  * @since 1.5.0.2
  * @return float Total paid
  */
 public function getTotalPaid()
 {
     $cache_id = 'order_invoice_paid_' . (int) $this->id;
     if (!Cache::isStored($cache_id)) {
         $amount = 0;
         $payments = OrderPayment::getByInvoiceId($this->id);
         foreach ($payments as $payment) {
             /** @var OrderPayment $payment */
             $amount += $payment->amount;
         }
         Cache::store($cache_id, $amount);
         return $amount;
     }
     return Cache::retrieve($cache_id);
 }
开发者ID:jpodracky,项目名称:dogs,代码行数:20,代码来源:OrderInvoice.php

示例15: setLastVisitedCategory

 public function setLastVisitedCategory()
 {
     $cache_id = 'blockcategories::setLastVisitedCategory';
     if (!Cache::isStored($cache_id)) {
         if (method_exists($this->context->controller, 'getCategory') && ($category = $this->context->controller->getCategory())) {
             $this->context->cookie->last_visited_category = $category->id;
         } elseif (method_exists($this->context->controller, 'getProduct') && ($product = $this->context->controller->getProduct())) {
             if (!isset($this->context->cookie->last_visited_category) || !Product::idIsOnCategoryId($product->id, array(array('id_category' => $this->context->cookie->last_visited_category))) || !Category::inShopStatic($this->context->cookie->last_visited_category, $this->context->shop)) {
                 $this->context->cookie->last_visited_category = (int) $product->id_category_default;
             }
         }
         Cache::store($cache_id, $this->context->cookie->last_visited_category);
     }
     return Cache::retrieve($cache_id);
 }
开发者ID:vadia007,项目名称:paintings,代码行数:15,代码来源:blockcategories.php


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