當前位置: 首頁>>代碼示例>>PHP>>正文


PHP myCriteria::getCriteriaCacheKey方法代碼示例

本文整理匯總了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;
 }
開發者ID:richhl,項目名稱:kalturaCE,代碼行數:25,代碼來源:entryPeer.php


注:本文中的myCriteria::getCriteriaCacheKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。