コード例 #1
0
ファイル: category.php プロジェクト: dozernz/server
 protected function countEntriesByCriteria($entryIds, $directOnly = false)
 {
     // Try to retrieve from cache
     $cacheKey = category::EXCEEDED_ENTRIES_COUNT_CACHE_PREFIX . $this->getId();
     $cacheStore = kCacheManager::getSingleLayerCache(kCacheManager::CACHE_TYPE_LOCK_KEYS);
     if ($cacheStore) {
         $countExceeded = $cacheStore->get($cacheKey);
         if ($countExceeded) {
             return null;
         }
     }
     // Query for entry count
     $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS);
     $filter = new entryFilter();
     $filter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE);
     if ($directOnly) {
         $filter->setCategoriesIdsMatchAnd($this->getId());
     } else {
         $filter->setCategoryAncestorId($this->getId());
     }
     if ($entryIds) {
         $filter->setIdNotIn($entryIds);
     }
     $filter->setLimit(1);
     $filter->attachToCriteria($baseCriteria);
     $baseCriteria->applyFilters();
     $count = $baseCriteria->getRecordsCount();
     // Save the result within the cache
     if ($count >= category::MAX_NUMBER_OF_ENTRIES_PER_CATEGORY) {
         if ($cacheStore) {
             $cacheStore->set($cacheKey, true, category::EXCEEDED_ENTRIES_COUNT_CACHE_EXPIRY);
         }
     }
     return $count;
 }