本文整理汇总了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;
}