コード例 #1
0
  @RequestMapping("{cacheName}/{key}/details")
  @ResponseBody
  public Object keyDetail(
      @PathVariable("cacheName") String cacheName, @PathVariable("key") String key, Model model) {

    Element element = cacheManager.getCache(cacheName).get(key);

    String dataPattern = "yyyy-MM-dd hh:mm:ss";
    Map<String, Object> data = Maps.newHashMap();
    data.put("objectValue", element.getObjectValue().toString());
    data.put("size", PrettyMemoryUtils.prettyByteSize(element.getSerializedSize()));
    data.put("hitCount", element.getHitCount());

    Date latestOfCreationAndUpdateTime = new Date(element.getLatestOfCreationAndUpdateTime());
    data.put(
        "latestOfCreationAndUpdateTime",
        DateFormatUtils.format(latestOfCreationAndUpdateTime, dataPattern));
    Date lastAccessTime = new Date(element.getLastAccessTime());
    data.put("lastAccessTime", DateFormatUtils.format(lastAccessTime, dataPattern));
    if (element.getExpirationTime() == Long.MAX_VALUE) {
      data.put("expirationTime", "不过期");
    } else {
      Date expirationTime = new Date(element.getExpirationTime());
      data.put("expirationTime", DateFormatUtils.format(expirationTime, dataPattern));
    }

    data.put("timeToIdle", element.getTimeToIdle());
    data.put("timeToLive", element.getTimeToLive());
    data.put("version", element.getVersion());

    return data;
  }
コード例 #2
0
 protected BounceProxyRecord getBounceProxyRecordFromElement(Element element) {
   BounceProxyRecord bpRecord = (BounceProxyRecord) element.getObjectValue();
   bpRecord.setFreshness(element.getLatestOfCreationAndUpdateTime());
   return bpRecord;
 }