...
|
...
|
@@ -26,16 +26,36 @@ public class SearchCacheService { |
|
|
private void addJSONObjectToCache(String key, JSONObject jsonObject, SearchCache searchCache) {
|
|
|
// 1、如果不适用缓存,则直接返回
|
|
|
if (!ISearchConstants.SEARCH_USE_CACHE) {
|
|
|
return;
|
|
|
return ;
|
|
|
}
|
|
|
// 2、如果缓存不存在,则直接返回
|
|
|
if (searchCache == null || searchCache.getCache() == null) {
|
|
|
return;
|
|
|
return ;
|
|
|
}
|
|
|
// 3、加入缓存
|
|
|
CacheObject cacheObject = new CacheObject(jsonObject);
|
|
|
searchCache.getCache().addOrUpdate(key, cacheObject, searchCache.getCacheInMinute());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 加入对象进缓存
|
|
|
*
|
|
|
* @param key
|
|
|
* @param jsonObject
|
|
|
*/
|
|
|
private String addJSONObjectToCacheAndReturn(String key, JSONObject jsonObject, SearchCache searchCache) {
|
|
|
// 1、如果不适用缓存,则直接返回
|
|
|
if (!ISearchConstants.SEARCH_USE_CACHE) {
|
|
|
return null;
|
|
|
}
|
|
|
// 2、如果缓存不存在,则直接返回
|
|
|
if (searchCache == null || searchCache.getCache() == null) {
|
|
|
return null;
|
|
|
}
|
|
|
// 3、加入缓存
|
|
|
CacheObject cacheObject = new CacheObject(jsonObject);
|
|
|
return searchCache.getCache().addAndReturn(key, cacheObject, searchCache.getCacheInMinute());
|
|
|
}
|
|
|
|
|
|
private void addJSONArrayToCache(String key, JSONArray jsonArray, SearchCache searchCache) {
|
|
|
// 1、如果不适用缓存,则直接返回
|
...
|
...
|
@@ -139,6 +159,10 @@ public class SearchCacheService { |
|
|
public void addJSONObjectToCache(SearchCache searchCache, String cacheKey, JSONObject jsonObject) {
|
|
|
this.addJSONObjectToCache(cacheKey, jsonObject, searchCache);
|
|
|
}
|
|
|
|
|
|
public String addJSONObjectToCacheAndReturn(SearchCache searchCache, String cacheKey, JSONObject jsonObject) {
|
|
|
return this.addJSONObjectToCacheAndReturn(cacheKey, jsonObject, searchCache);
|
|
|
}
|
|
|
|
|
|
public void addJSONObjectToCache(SearchCache searchCache, String indexName, SearchParam searchParam, JSONObject jsonObject) {
|
|
|
String key = this.genSearchParamString(indexName, searchParam);
|
...
|
...
|
|