Examples of Ehcache


Examples of net.sf.ehcache.Ehcache

  @Test
  public void testPutRetreive() {
    Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
    CacheManager cacheManager = CacheManager.getInstance();
    Ehcache ehcache = cacheManager.getEhcache("testCache");

    ehcache.put(new Element("testKey", "testValue"));
    stats(ehcache);
    Assert.assertEquals("testValue", ehcache.get("testKey").getObjectValue());
  }
View Full Code Here

Examples of org.jeecgframework.core.annotation.Ehcache

    Object[] arguments = joinPoint.getArgs()
   
    //试图得到标注的Ehcache类
    @SuppressWarnings("unused")
    Method[] methods = joinPoint.getTarget().getClass().getMethods();
    Ehcache flag = null;
    for(Method m:methods){
      if(m.getName().equals(methodName)){
        Class[] tmpCs = m.getParameterTypes()
                if(tmpCs.length==arguments.length){ 
                  flag = m.getAnnotation(Ehcache.class);
            break;
           
      }
    }
    if(flag==null){
      return null;
    }
    //Ehcache flag =joinPoint.getTarget().getClass().getMethod(methodName).getAnnotation(Ehcache.class);
    Object result;
    String cacheKey = getCacheKey(targetName, methodName, arguments);
   
    Element element = null;
    if(flag.eternal()){
      //永久缓存
       element = dictCache.get(cacheKey);
    }else{
      //临时缓存
       element = eternalCache.get(cacheKey);
    }
   

    if (element == null) {
      if ((arguments != null) && (arguments.length != 0)) {
        result = joinPoint.proceed(arguments);
      } else {
        result = joinPoint.proceed();
      }

      element = new Element(cacheKey, (Serializable) result);
      if(flag.eternal()){
        //永久缓存
        dictCache.put(element);
      }else{
        //临时缓存
        eternalCache.put(element);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.