Example #1
0
    @SuppressWarnings("unchecked")
    @Override
    public V get(K key) throws CacheException {
      if (key == null) {
        return null;
      }

      V v = null;
      HttpServletRequest request = Servlets.getRequest();
      if (request != null) {
        v = (V) request.getAttribute(cacheKeyName);
        if (v != null) {
          return v;
        }
      }

      V value = null;
      value = (V) getSession().getAttribute(cacheKeyName);
      logger.debug(
          "get {} {} {}", cacheKeyName, key, request != null ? request.getRequestURI() : "");

      if (request != null && value != null) {
        request.setAttribute(cacheKeyName, value);
      }
      return value;
    }
Example #2
0
    @Override
    public V put(K key, V value) throws CacheException {
      if (key == null) {
        return null;
      }

      getSession().setAttribute(cacheKeyName, value);

      if (logger.isDebugEnabled()) {
        HttpServletRequest request = Servlets.getRequest();
        logger.debug(
            "put {} {} {}", cacheKeyName, key, request != null ? request.getRequestURI() : "");
      }

      return value;
    }