Package loxia.support.cache.annotation

Examples of loxia.support.cache.annotation.Cacheable


  @Around("@annotation(loxia.support.cache.annotation.Cacheable)")
  public Object doGet(ProceedingJoinPoint pjp) throws Throwable{
    Method m = getMethod(pjp, Cacheable.class);
    Map<String, Object> params = getParams(m, pjp.getArgs());
    Cacheable c = m.getAnnotation(Cacheable.class);
    String methodName = c.value().equals("") ? EncodeUtil.intToBase62(m.getDeclaringClass().getSimpleName().hashCode()) + "."
        + EncodeUtil.intToBase62(m.getName().hashCode()) : c.value();
    /*
     * String methodName = c.value().equals("") ? m.getDeclaringClass().getSimpleName() + "." + m.getName() : c.value();
     */
    String cacheKey = getCacheKey(methodName, params);
    logger.debug("get cache with key: {}", cacheKey);
    Object value = cacheClient.get(cacheKey);
    if (value != null){
      if (value instanceof NullObject)
        value = null;
      logger.debug("Cached value: {} will be returned as type {} with key [{}]", new Object[] { value, m.getReturnType(), cacheKey });
      return value;
    }else{
      value = pjp.proceed(pjp.getArgs());
      cacheValue(methodName, c.cacheKey(), cacheKey, value == null ? NULL : value, c.expire(), params);
      return value;
    }
  }
View Full Code Here

TOP

Related Classes of loxia.support.cache.annotation.Cacheable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.