本文整理匯總了PHP中Billrun_Factory::cache方法的典型用法代碼示例。如果您正苦於以下問題:PHP Billrun_Factory::cache方法的具體用法?PHP Billrun_Factory::cache怎麽用?PHP Billrun_Factory::cache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Billrun_Factory
的用法示例。
在下文中一共展示了Billrun_Factory::cache方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: cleanAccountCache
/**
* method to clean account cache
*
* @param int $aid
*
* @return true on success, else false
*/
protected function cleanAccountCache($aid)
{
$cache = Billrun_Factory::cache();
if (empty($cache)) {
return false;
}
$aids = array_unique(array_diff(Billrun_Util::verify_array(explode(',', $aid), 'int'), array(0)));
$billrunKey = Billrun_Util::getBillrunKey(time());
$cachePrefix = 'balance_';
// this is not the action name because it's clear the balance cache
foreach ($aids as $aid) {
$cleanCacheKeys = array(Billrun_Util::generateArrayStamp(array_values(array('aid' => $aid, 'subscribers' => array(), 'stamp' => $billrunKey))), Billrun_Util::generateArrayStamp(array_values(array('aid' => $aid, 'subscribers' => null, 'stamp' => (int) $billrunKey))), Billrun_Util::generateArrayStamp(array_values(array('aid' => $aid, 'subscribers' => "", 'stamp' => (int) $billrunKey))), Billrun_Util::generateArrayStamp(array_values(array('aid' => $aid, 'subscribers' => 0, 'stamp' => (int) $billrunKey))));
foreach ($cleanCacheKeys as $cacheKey) {
$cache->remove($cacheKey, $cachePrefix);
}
}
return true;
}
示例2: cache
/**
* method to store and fetch by global cache layer
*
* @param type $params params to be used by cache to populate and store
*
* @return mixed the cached results
*/
protected function cache($params)
{
if (!isset($params['stampParams'])) {
$params['stampParams'] = $params['fetchParams'];
}
$cache = Billrun_Factory::cache();
if (empty($cache)) {
return $this->fetchData($params['fetchParams']);
}
$actionName = $this->getAction();
$cachePrefix = $this->getCachePrefix();
$cacheKey = Billrun_Util::generateArrayStamp(array_values($params['stampParams']));
$cachedData = $cache->get($cacheKey, $cachePrefix);
if (empty($cachedData)) {
$cachedData = $this->fetchData($params['fetchParams']);
$lifetime = Billrun_Factory::config()->getConfigValue('api.cacheLifetime.' . $actionName, $this->getCacheLifeTime());
$cache->set($cacheKey, $cachedData, $cachePrefix, $lifetime);
} else {
Billrun_Factory::log()->log("Fetch data from cache for " . $actionName . " api call", Zend_Log::INFO);
}
return $cachedData;
}
示例3: cache
/**
* method to retrieve the cache instance
*
* @return Billrun_Cache
*/
public static function cache()
{
try {
if (!self::$cache) {
$args = self::config()->getConfigValue('cache', array());
if (empty($args)) {
return false;
}
self::$cache = Billrun_Cache::getInstance($args);
}
return self::$cache;
} catch (Exception $e) {
Billrun_Factory::log('Cache instance cannot be generated', Zend_Log::ALERT);
}
return false;
}
示例4: cache
/**
* method to retrieve the cache instance
*
* @return Billrun_Cache
*/
public static function cache()
{
if (!self::$cache) {
$args = self::config()->getConfigValue('cache', array());
if (empty($args)) {
return false;
}
self::$cache = Billrun_Cache::getInstance($args);
}
return self::$cache;
}