java清理缓存实现
侧边栏壁纸
  • 累计撰写 57 篇文章
  • 累计收到 12 条评论

java清理缓存实现

龙流
2022-06-08 / 0 评论 / 50 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2022年06月08日,已超过184天没有更新,若内容或图片失效,请留言反馈。

前台代码:

<script>
  function CleanConfirm(){
    var url="/devindex/function";
    var data={f:'clearCache'};
    $.ajax({
      url: url,
      type: "post",
      dataType: "json",
      contentType: "application/json; charset=utf8",
      data: data,
      success: function(data) {
        if(data.success){
            layerInfo(data.msg);
        }else{
            layerInfo(data.msg);
        }
      }
    });
  }
</script>

后台代码:

@ResponseBody
    @RequestMapping({"/function"})
    public Map function(String p_dm, @RequestParam Map<String, Object> paramMap, Model model, HttpServletRequest request, HttpServletResponse response) {
        if ("clearCache".equals(paramMap.get("f"))) {
            CommonCacheManager commonCacheManager = CommonCacheManager.getCommonCacheManager();
            String cacheName = CACHENAME.COMMONAPICONFIG.name();
            List<PFunctionsubEntity> pFunctionsubEntities = this.pFunctionSubService.GetOneDataByDm(p_dm);

            for(int i = 0; i < pFunctionsubEntities.size(); ++i) {
                PFunctionsubEntity pFunctionsubEntity = (PFunctionsubEntity)pFunctionsubEntities.get(i);
                commonCacheManager.removeCacheValue(cacheName, pFunctionsubEntity.getId());
                commonCacheManager.removeCacheValue(cacheName, pFunctionsubEntity.getDm());
                commonCacheManager.removeCacheValue(cacheName, pFunctionsubEntity.getMainid() + pFunctionsubEntity.getDm());
                commonCacheManager.removeCacheValue(cacheName, pFunctionsubEntity.getId() + PFunctiontjoptEntity.class.toString());
                commonCacheManager.clearCache(pFunctionsubEntity.getDm());
            }

            if (StringUtil.isEmptyOrLength0(p_dm)) {
                commonCacheManager.clearCache(cacheName);
                commonCacheManager.clearCache((String)null);
            }

            Map resMap = new HashMap();
            resMap.put("success", "true");
            resMap.put("msg", "clearCache:" + (StringUtil.isEmptyOrLength0(p_dm) ? "all" : p_dm));
            return resMap;
        }
}
0

评论 (0)

取消