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


PHP Company::setCompanyJobsCache方法代碼示例

本文整理匯總了PHP中app\Company::setCompanyJobsCache方法的典型用法代碼示例。如果您正苦於以下問題:PHP Company::setCompanyJobsCache方法的具體用法?PHP Company::setCompanyJobsCache怎麽用?PHP Company::setCompanyJobsCache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Company的用法示例。


在下文中一共展示了Company::setCompanyJobsCache方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getAll

 public static function getAll(array $args = [])
 {
     $max = '+inf';
     $min = '-inf';
     $limit = 20;
     if (!empty($args['limit'])) {
         $limit = intval($args['limit']);
     }
     $offset = 0;
     if (!empty($args['offset'])) {
         $offset = intval($args['offset']);
     }
     $flag = '';
     if (!empty($args['flag'])) {
         $flag = $args['flag'];
     }
     $dma_code = null;
     $dma_cache_key = '';
     // request DMA jobs cache if user requested jobs by location
     if (!empty($args['code']) && ($args['code'] >= 500 && $args['code'] <= 881)) {
         $dma_code = $args['code'];
         $dma_cache_key = self::getJobsByDmaCahceKey($dma_code);
         self::setJobsByDmaCache($dma_code);
     } else {
         if (!empty($args['location'])) {
             // lookup dma code
             $dma_code = DmaMap::getDmaCode($args['location']);
             if (!empty($dma_code)) {
                 $args['code'] = $dma_code;
                 // will be return as a  part of a payload
                 self::setJobsByDmaCache($dma_code);
                 $dma_cache_key = self::getJobsByDmaCahceKey($dma_code);
             }
         }
     }
     $kw_list = [];
     $kw_cache_list = [];
     $cache_key_union_out = '';
     $result_type = '';
     $cache_key_intersect_out = 'intersect';
     $cache_key_union_out = 'union';
     $union_out = '';
     $key_out = '';
     $intersect_out = '';
     $intersect_in = [];
     // request KEYWORD jobs caches if user requested jobs by keyword
     if (!empty($args['keyword'])) {
         $req_k = explode(' ', strtolower($args['keyword']));
         foreach ($req_k as $k) {
             $kw = trim($k);
             if (!empty($kw) && !in_array($kw, $kw_list)) {
                 $cache_key_union_out .= ':' . $kw;
                 $cache_key_intersect_out .= ':' . $kw;
                 $kw_list[] = $kw;
             }
         }
         if (!empty($kw_list)) {
             foreach ($kw_list as $ck) {
                 // request jobs by keyword
                 $kw_cache_key = Keyword::getKeywordJobsCacheKey($ck);
                 Keyword::setKeywordJobsCache($ck);
                 $kw_cache_list[] = $kw_cache_key;
                 // request jobs by company keyword
                 $kw_company_cache_key = Keyword::getKeywordCompaniesCacheKey($ck);
                 Keyword::setKeywordCompaniesCache($ck);
                 $all_companies_str_ids = Redis::smembers($kw_company_cache_key);
                 if (!empty($all_companies_str_ids)) {
                     foreach ($all_companies_str_ids as $c_str_id) {
                         $company_jobs_cache = Company::getCompanyJobsCacheKey($c_str_id);
                         Company::setCompanyJobsCache($c_str_id);
                         $kw_cache_list[] = $company_jobs_cache;
                     }
                 }
             }
         }
     }
     if (!empty($dma_code)) {
         // DMA - Yes
         if (!empty($kw_cache_list)) {
             // Keyword - Yes
             if (count($kw_cache_list) == 1) {
                 // only one keyword - intersect vars
                 $intersect_out = $cache_key_intersect_out . ':' . $dma_code;
                 $intersect_in = [$kw_cache_list[0], $dma_cache_key];
                 $key_out = $intersect_out;
             } else {
                 // multiple keywords
                 foreach ($kw_cache_list as $kin) {
                     $keys_in[] = $kin;
                 }
                 // union first
                 $union_out = $cache_key_union_out;
                 Redis::zunionstore($union_out, $keys_in, ['aggregate' => 'sum']);
                 Redis::expire($union_out, 60 * 5);
                 // intersect vars
                 $intersect_out = $cache_key_intersect_out . ':' . $dma_code;
                 $intersect_in = [$union_out, $dma_cache_key];
                 $key_out = $intersect_out;
             }
             Redis::zinterstore($intersect_out, $intersect_in, ['aggregate' => 'sum']);
//.........這裏部分代碼省略.........
開發者ID:lucy-udalykh,項目名稱:samples,代碼行數:101,代碼來源:Job.php


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