...
|
...
|
@@ -3,7 +3,6 @@ |
|
|
*/
|
|
|
'use strict';
|
|
|
const _ = require('lodash');
|
|
|
const Fn = require('lodash/fp');
|
|
|
const md5 = require('md5');
|
|
|
|
|
|
const config = global.yoho.config;
|
...
|
...
|
@@ -22,13 +21,15 @@ const GLOBAL_BASE_URI = '/product/global/list'; |
|
|
|
|
|
// 缓存生效时间
|
|
|
const CACHE_TIME_S = 60;
|
|
|
const UNUSEDKEY = ['page', 'limit', 'need_filter', 'order'];
|
|
|
|
|
|
function getSearchCacheKey(params) {
|
|
|
let removeUnusedKey = Fn.omit(['page', 'limit', 'need_filter', 'order']);
|
|
|
let sortByKey = Fn.pipe(Fn.toPairs, Fn.sortBy(0), Fn.flatten);
|
|
|
let genKey = Fn.pipe(Fn.cloneDeep, removeUnusedKey, sortByKey, Fn.join('_'));
|
|
|
const paramList = Object.keys(params)
|
|
|
.filter(k => !_.some(UNUSEDKEY, key => key === k))
|
|
|
.sort();
|
|
|
const paramsStr = _.join(_.map(paramList, k => `${k}_${params[k] || ''}`), '_');
|
|
|
|
|
|
return 'search_custom_' + md5(genKey(params));
|
|
|
return 'search_custom_' + md5(paramsStr);
|
|
|
}
|
|
|
|
|
|
function _saveCache(key, kv, cacheTime) {
|
...
|
...
|
|