本文整理汇总了PHP中app\Company::getCompanyJobsCacheKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Company::getCompanyJobsCacheKey方法的具体用法?PHP Company::getCompanyJobsCacheKey怎么用?PHP Company::getCompanyJobsCacheKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Company
的用法示例。
在下文中一共展示了Company::getCompanyJobsCacheKey方法的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']);
//.........这里部分代码省略.........