Authored by hugufei

添加测试缓存的测试类

package com.yoho.search.restapi.tools;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yoho.search.common.cache.CacheType;
import com.yoho.search.common.cache.aop.SearchCacheAble;
import com.yoho.search.common.utils.HttpServletRequestUtils;
import com.yoho.search.models.SearchApiResult;
@Controller
public class TestSearchCacheController {
@Autowired
private TestSearchCacheService testSearchCacheService;
@RequestMapping(method = RequestMethod.GET, value = "/testSearchCache")
@ResponseBody
public SearchApiResult searchHelper(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
return this.helper(paramMap);
}
@SearchCacheAble(cacheInMinute = 10, cacheType = CacheType.SEARCH_REDIS, cacheName = "testSearchCacheService")
public SearchApiResult helper(Map<String, String> paramMap) {
return new SearchApiResult().setData(paramMap);
}
}
... ...
package com.yoho.search.restapi.tools;
import java.util.Map;
import org.springframework.stereotype.Component;
import com.yoho.search.common.cache.CacheType;
import com.yoho.search.common.cache.aop.SearchCacheAble;
import com.yoho.search.models.SearchApiResult;
@Component
public class TestSearchCacheService {
@SearchCacheAble(cacheInMinute = 10, cacheType = CacheType.SEARCH_REDIS, cacheName = "testSearchCacheService")
public SearchApiResult helper(Map<String, String> paramMap) {
return new SearchApiResult().setData(paramMap);
}
}
... ...