|
|
package com.yohoufo.promotion.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.yohoufo.common.annotation.IgnoreSession;
|
|
|
import com.yohoufo.common.annotation.IgnoreSignature;
|
|
|
import com.yohoufo.common.cache.CacheClient;
|
|
|
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.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
/**
|
|
|
* Created by jiexiang.wu on 2018/11/21.
|
|
|
*/
|
|
|
@Controller
|
|
|
@RequestMapping(value = "/redis")
|
|
|
public class RedisTestController {
|
|
|
|
|
|
@Autowired
|
|
|
private CacheClient cacheClient;
|
|
|
|
|
|
@RequestMapping("/redis_get")
|
|
|
@ResponseBody
|
|
|
@IgnoreSession
|
|
|
@IgnoreSignature
|
|
|
public String get(@RequestParam String key, @RequestParam String className) {
|
|
|
try {
|
|
|
Class clazz = Class.forName(className);
|
|
|
Object result = cacheClient.get(key, clazz);
|
|
|
return JSON.toJSONString(result);
|
|
|
} catch (Exception ex) {
|
|
|
return "happen exception";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/redis_delete")
|
|
|
@ResponseBody
|
|
|
@IgnoreSession
|
|
|
@IgnoreSignature
|
|
|
public String delete(@RequestParam String key) {
|
|
|
cacheClient.delete(key);
|
|
|
return "ok";
|
|
|
}
|
|
|
} |
...
|
...
|
|