本文整理匯總了PHP中myCriteria::getCriteriaCacheKey方法的典型用法代碼示例。如果您正苦於以下問題:PHP myCriteria::getCriteriaCacheKey方法的具體用法?PHP myCriteria::getCriteriaCacheKey怎麽用?PHP myCriteria::getCriteriaCacheKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類myCriteria
的用法示例。
在下文中一共展示了myCriteria::getCriteriaCacheKey方法的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;
}