本文整理汇总了PHP中entryPeer::entry_count_cache方法的典型用法代码示例。如果您正苦于以下问题:PHP entryPeer::entry_count_cache方法的具体用法?PHP entryPeer::entry_count_cache怎么用?PHP entryPeer::entry_count_cache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entryPeer
的用法示例。
在下文中一共展示了entryPeer::entry_count_cache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doCountWithCache
public static function doCountWithCache(Criteria $criteria, $cache_expiry_in_seconds = 600)
{
$cache_key = myCriteria::getCriteriaCacheKey($criteria);
if (!self::$entry_count_cache) {
self::$entry_count_cache = new myCache("entry_count_cache", $cache_expiry_in_seconds);
}
if ($count_result = self::$entry_count_cache->get($cache_key)) {
KalturaLog::log(__METHOD__ . ": count from cache [{$count_result}] for cacheKey [{$cache_key}]");
return $count_result;
} else {
KalturaLog::log(__METHOD__ . ": NO count from cache [{$count_result}] for cacheKey [{$cache_key}]");
$count_result = self::doCount($criteria);
// if we have a count result worth caching - cache it.
// one the one hand, for few results, it's nice to display rapid differences, therefore cache only if above the MIN_COUNT_RESULT_TO_CACHE threshold
// one the other hand - it can be that there are very little few resuls (sometimes 0) and still importatn to cache even more than when many results
// for now - go for the first version - cache above threshold.
if ($count_result && $count_result > self::MIN_COUNT_RESULT_TO_CACHE) {
self::$entry_count_cache->put($cache_key, $count_result);
KalturaLog::log(__METHOD__ . ": Setting count in cache [{$count_result}] for cacheKey [{$cache_key}]");
} else {
KalturaLog::log(__METHOD__ . ": Did NOT Set count in cache [{$count_result}] for cacheKey [{$cache_key}]");
}
}
return $count_result;
}