Examples of CachePolicy


Examples of com.pccw.hessian.support.cache.CachePolicy

  private HashMap<String,CacheContainner> cache=new HashMap<String, CacheContainner>();
 
  //不需要判断policy为null,policy为null,认定为不适用缓存,不会掉用此方法
  @Override
  public boolean ifReturnFromCahce(Method method, Object[] args) {
    CachePolicy policy=method.getAnnotation(CachePolicy.class);
    if(policy.expires() < 0){
      System.out.println("没有有效期,false");
      return false;
    }
    try {
      String key=getCacheKey(method,args);
      //String key=policy.keyGenerater().newInstance().generatKey(method, args);System.out.println("生成的缓存key:"+key);
      if(cache.containsKey(key)==false){System.out.println("有缓存规则,但缓存中不存在false");
        return false;
      }
      CacheContainner cc=cache.get(key);
      if((System.currentTimeMillis()-cc.brith) < policy.expires()){System.out.println("有缓存规则,且缓存中存在,且没过期true");
        return true;
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

Examples of com.pccw.hessian.support.cache.CachePolicy

      e.printStackTrace();
    }
  }
 
  private String getCacheKey(Method method, Object[] args) throws InstantiationException, IllegalAccessException{
    CachePolicy policy=method.getAnnotation(CachePolicy.class);
    return "".equals(policy.key())?policy.keyGenerater().newInstance().generatKey(method, args):policy.key();
  }
View Full Code Here

Examples of net.sf.pipet.api.CachePolicy

    return cache_policies.get(name);
  }
 
  public CachePolicy getDefaultCachePolicy()
  {
    CachePolicy cp = root_module.getCachePolicy();
    return cp==null ? Cache.NO_CACHE : cp;
  }
View Full Code Here

Examples of org.eclipse.persistence.descriptors.CachePolicy

    protected Object buildObjectInUnitOfWork(ObjectBuildingQuery query, JoinedAttributeManager joinManager, AbstractRecord databaseRow, UnitOfWorkImpl unitOfWork, Object primaryKey, CacheKey preFetchedCacheKey, ClassDescriptor concreteDescriptor) throws DatabaseException, QueryException {
        // When in transaction we are reading via the write connection
        // and so do not want to corrupt the shared cache with dirty objects.
        // Hence we build and refresh clones directly from the database row.
        // PERF: Allow the session cached to still be used after early transaction if isolation setting has been set.
        CachePolicy cachePolicy = concreteDescriptor.getCachePolicy();
        if (!cachePolicy.shouldUseSessionCacheInUnitOfWorkEarlyTransaction()) {
            if (((unitOfWork.hasCommitManager() && unitOfWork.getCommitManager().isActive())
                    || unitOfWork.wasTransactionBegunPrematurely()
                    || cachePolicy.shouldIsolateObjectsInUnitOfWork()
                    || cachePolicy.shouldIsolateProtectedObjectsInUnitOfWork()
                    || query.shouldStoreBypassCache())
                        && (!unitOfWork.isClassReadOnly(concreteDescriptor.getJavaClass(), concreteDescriptor))) {
                // It is easier to switch once to the correct builder here.
                return concreteDescriptor.getObjectBuilder().buildWorkingCopyCloneFromRow(query, joinManager, databaseRow, unitOfWork, primaryKey, preFetchedCacheKey);
            }
View Full Code Here

Examples of org.gradle.api.internal.artifacts.configurations.dynamicversion.CachePolicy

            return new NoRepositoriesResolver();
        }

        ResolutionStrategyInternal resolutionStrategy = configuration.getResolutionStrategy();
        ResolutionRules resolutionRules = resolutionStrategy.getResolutionRules();
        CachePolicy cachePolicy = resolutionStrategy.getCachePolicy();

        startParameterResolutionOverride.addResolutionRules(resolutionRules);

        UserResolverChain userResolverChain = new UserResolverChain(versionSelectorScheme, versionComparator, resolutionStrategy.getComponentSelection());
        RepositoryChain parentLookupResolver = new ParentModuleLookupResolver(userResolverChain, cacheLockingManager);
View Full Code Here

Examples of org.jboss.dna.graph.cache.CachePolicy

            BasicCachePolicy cachePolicy = new BasicCachePolicy();
            Property timeToLiveProperty = getRepository.getPropertiesByName().get(nameFactory.create(CACHE_POLICY_TIME_TO_LIVE_CONFIG_PROPERTY_NAME));
            if (timeToLiveProperty != null && !timeToLiveProperty.isEmpty()) {
                cachePolicy.setTimeToLive(longFactory.create(timeToLiveProperty.getValues().next()), TimeUnit.MILLISECONDS);
            }
            CachePolicy defaultCachePolicy = cachePolicy.isEmpty() ? null : cachePolicy.getUnmodifiable();
            return new FederatedRepositoryConfig(repositoryName, cacheProjection, sourceProjections, defaultCachePolicy);
        } catch (InvalidPathException err) {
            I18n msg = FederationI18n.federatedRepositoryCannotBeFound;
            throw new FederationException(msg.text(repositoryName));
        } finally {
View Full Code Here

Examples of org.jboss.dna.graph.cache.CachePolicy

            ref.add(new StringRefAddr(DRIVER_CLASS_NAME, getDriverClassName()));
        }
       
        if (getDefaultCachePolicy() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            CachePolicy policy = getDefaultCachePolicy();
            try {
                ObjectOutputStream oos = new ObjectOutputStream(baos);
                oos.writeObject(policy);
                ref.add(new BinaryRefAddr(DEFAULT_CACHE_POLICY, baos.toByteArray()));
            } catch (IOException e) {
                I18n msg = JdbcMetadataI18n.errorSerializingCachePolicyInSource;
                throw new RepositorySourceException(getName(), msg.text(policy.getClass().getName(), getName()), e);
            }
        }
        ref.add(new StringRefAddr(RETRY_LIMIT, Integer.toString(getRetryLimit())));
        // return it
        return ref;
View Full Code Here

Examples of org.jboss.dna.graph.cache.CachePolicy

    }

    @Test
    public void shouldAllowAddingRepositorySourceInstance() {
        UUID rootUuid = UUID.randomUUID();
        CachePolicy cachePolicy = new ImmutableCachePolicy(100);

        // Update the configuration and save it ...
        configuration.repositorySource("name")
                     .usingClass(InMemoryRepositorySource.class)
                     .setRetryLimit(100)
View Full Code Here

Examples of org.jboss.dna.graph.cache.CachePolicy

        public Location getLocation() {
            return request.getActualLocationOfNode();
        }

        public DateTime getExpirationTime() {
            CachePolicy policy = request.getCachePolicy();
            return policy == null ? null : request.getTimeLoaded().plus(policy.getTimeToLive(), TimeUnit.MILLISECONDS);
        }
View Full Code Here

Examples of org.jboss.dna.graph.cache.CachePolicy

        if (getDefaultWorkspaceName() != null) {
            ref.add(new StringRefAddr(DEFAULT_WORKSPACE_NAME_ATTR, getDefaultWorkspaceName()));
        }
        if (getDefaultCachePolicy() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            CachePolicy policy = getDefaultCachePolicy();
            try {
                ObjectOutputStream oos = new ObjectOutputStream(baos);
                oos.writeObject(policy);
                ref.add(new BinaryRefAddr(DEFAULT_CACHE_POLICY_ATTR, baos.toByteArray()));
            } catch (IOException e) {
                I18n msg = GraphI18n.errorSerializingInMemoryCachePolicyInSource;
                throw new RepositorySourceException(getName(), msg.text(policy.getClass().getName(), getName()), e);
            }
        }
        ref.add(new StringRefAddr(RETRY_LIMIT_ATTR, Integer.toString(getRetryLimit())));
        return ref;
    }
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.