从数据源中获取最新数据，并写入缓存。注意：这里不使用“拿来主义”机制，是因为当前可能是更新数据的方法。

@param pjp   CacheAopProxyChain
@param cache Cache注解
@return 最新数据
@throws Throwable 异常
325110
private Object writeOnly(CacheAopProxyChain pjp, Cache cache) throws Throwable {
        DataLoaderFactory factory = DataLoaderFactory.getInstance();
        DataLoader dataLoader = factory.getDataLoader();
        CacheWrapper<Object> cacheWrapper;
        try {
            cacheWrapper = dataLoader.init(pjp, cache, this).getData().getCacheWrapper();
        } catch (Throwable e) {
            throw e;
        } finally {
            factory.returnObject(dataLoader);
        }
        Object result = cacheWrapper.getCacheObject();
        Object[] arguments = pjp.getArgs();
        if (scriptParser.isCacheable(cache, pjp.getTarget(), arguments, result)) {
            CacheKeyTO cacheKey = getCacheKey(pjp, cache, result);
            // 注意：这里只能获取AutoloadTO，不能生成AutoloadTO
            AutoLoadTO autoLoadTO = autoLoadHandler.getAutoLoadTO(cacheKey);
            try {
                writeCache(pjp, pjp.getArgs(), cache, cacheKey, cacheWrapper);
                if (null != autoLoadTO) {
                    // 同步加载时间
                    autoLoadTO.setLastLoadTime(cacheWrapper.getLastLoadTime())
                            // 同步过期时间
                            .setExpire(cacheWrapper.getExpire());
                }
            } catch (Exception ex) {
                log.error(ex.getMessage(), ex);
            }
        }
        return result;
    }
1205359
protected final PrcPrepaymentFromCopy<RS> createPutPrcPrepaymentFromCopy(
    final Map<String, Object> pAddParam) throws Exception {
    PrcPrepaymentFromCopy<RS> proc = new PrcPrepaymentFromCopy<RS>();
    @SuppressWarnings("unchecked")
    IEntityProcessor<PrepaymentFrom, Long> procDlg =
      (IEntityProcessor<PrepaymentFrom, Long>)
        lazyGetPrcAccEntityPbWithSubaccCopy(pAddParam);
    proc.setPrcAccEntityPbWithSubaccCopy(procDlg);
    proc.setSrvTypeCode(getSrvTypeCode());
    //assigning fully initialized object:
    this.processorsMap.put(PrcPrepaymentFromCopy.class.getSimpleName(), proc);
    return proc;
  }
1097172
public static PutFromLoadValidator removeFromCache(AdvancedCache cache) {
      AsyncInterceptorChain chain = cache.getAsyncInterceptorChain();
      BasicComponentRegistry cr = cache.getComponentRegistry().getComponent(BasicComponentRegistry.class);

		chain.removeInterceptor(TxPutFromLoadInterceptor.class);
		chain.removeInterceptor(NonTxPutFromLoadInterceptor.class);

      chain.getInterceptors().stream()
            .filter(BaseInvalidationInterceptor.class::isInstance).findFirst().map(AsyncInterceptor::getClass)
            .ifPresent(invalidationClass -> {
               InvalidationInterceptor invalidationInterceptor = new InvalidationInterceptor();
               cr.replaceComponent(InvalidationInterceptor.class.getName(), invalidationInterceptor, true);
               cr.getComponent(InvalidationInterceptor.class).running();
               chain.replaceInterceptor(invalidationInterceptor, invalidationClass);
            });

      chain.getInterceptors().stream()
            .filter(LockingInterceptor.class::isInstance).findFirst().map(AsyncInterceptor::getClass)
            .ifPresent(invalidationClass -> {
               NonTransactionalLockingInterceptor lockingInterceptor = new NonTransactionalLockingInterceptor();
               cr.replaceComponent(NonTransactionalLockingInterceptor.class.getName(), lockingInterceptor, true);
               cr.getComponent(NonTransactionalLockingInterceptor.class).running();
               chain.replaceInterceptor(lockingInterceptor, LockingInterceptor.class);
            });

		CacheCommandInitializer cci = cr.getComponent(CacheCommandInitializer.class).running();
		return cci.removePutFromLoadValidator(cache.getName());
	}
1338549
protected final PrcPaymentToCopy<RS> createPutPrcPaymentToCopy(
    final Map<String, Object> pAddParam) throws Exception {
    PrcPaymentToCopy<RS> proc = new PrcPaymentToCopy<RS>();
    @SuppressWarnings("unchecked")
    IEntityProcessor<PaymentTo, Long> procDlg =
      (IEntityProcessor<PaymentTo, Long>)
        lazyGetPrcAccEntityPbWithSubaccCopy(pAddParam);
    proc.setPrcAccEntityPbWithSubaccCopy(procDlg);
    //assigning fully initialized object:
    this.processorsMap.put(PrcPaymentToCopy.class.getSimpleName(), proc);
    return proc;
  }
1247734
private CompletableFuture<Void> completeCache(ByteString cacheName) throws Throwable {
      TxState state = globalTxTable.getState(new CacheXid(cacheName, xid));
      HotRodServer.CacheInfo cacheInfo =
         server.getCacheInfo(cacheName.toString(), header.getVersion(), header.getMessageId(), true);
      AdvancedCache<?, ?> cache = server.cache(cacheInfo, header, subject);
      RpcManager rpcManager = cache.getRpcManager();
      if (rpcManager == null || rpcManager.getAddress().equals(state.getOriginator())) {
         if (isTraceEnabled()) {
            log().tracef("[%s] Completing local executed transaction.", xid);
         }
         return asyncCompleteLocalTransaction(cache, state.getTimeout());
      } else if (rpcManager.getMembers().contains(state.getOriginator())) {
         if (isTraceEnabled()) {
            log().tracef("[%s] Forward remotely executed transaction to %s.", xid, state.getOriginator());
         }
         return forwardCompleteCommand(cacheName, rpcManager, state);
      } else {
         if (isTraceEnabled()) {
            log().tracef("[%s] Originator, %s, left the cluster.", xid, state.getOriginator());
         }
         return completeWithRemoteCommand(cache, rpcManager, state);
      }
   }
259603
@Around("anyPublicMethod() && @annotation(disconfItem)")
    public Object decideAccess(ProceedingJoinPoint pjp, DisconfItem disconfItem) throws Throwable {

        if (DisClientConfig.getInstance().ENABLE_DISCONF) {
            //
            // 请求仓库配置数据
            //
            DisconfStoreProcessor disconfStoreProcessor = DisconfStoreProcessorFactory.getDisconfStoreItemProcessor();
            Object ret = disconfStoreProcessor.getConfig(null, disconfItem.key());
            if (ret != null) {
                LOGGER.debug("using disconf store value: (" + disconfItem.key() + " , " + ret + ")");
                return ret;
            }
        }

        Object rtnOb;

        try {
            // 返回原值
            rtnOb = pjp.proceed();
        } catch (Throwable t) {
            LOGGER.info(t.getMessage());
            throw t;
        }

        return rtnOb;
    }
1173548
public static SqlParamsPairs getUpdateFromObject(Object po) throws Exception{
		
		//用来存放insert语句
		StringBuffer updateSql = new StringBuffer();
		
		//用来存放where语句
		StringBuffer whereSql = new StringBuffer();
		
		//用来存放参数值
		List<Object> params = new ArrayList<Object>();
		
		//用来存储id
		Object idValue = null;
		
		//分析表名
		String tableName = getTableName(po.getClass());
		
		updateSql.append("update " + tableName + " set");
		
		//分析列
		Field[] fields = po.getClass().getDeclaredFields();
		
		//用于计数
		int count = 0;
		for (int i = 0; i < fields.length; i++) {
			Field f = fields[i];
			
			//获取具体参数值
			Method getter = getGetter(po.getClass(),f);
			
			if(getter == null){
				continue;
			}
			
			Object value = getter.invoke(po);
			if(value == null){
				//如果参数值是null就直接跳过（不允许覆盖为null值，规范要求更新的每个字段都要有值，没有值就是空字符串）
				continue;
			}
			
			Transient tranAnno = getter.getAnnotation(Transient.class);
			if(tranAnno != null){
				//如果有 Transient 标记直接跳过
				continue;
			}
			
			//获取字段名
			String columnName = getColumnNameFromGetter(getter,f);
			
			//看看是不是主键
			Id idAnno = getter.getAnnotation(Id.class);
			if(idAnno != null){
				//如果是主键
				whereSql.append(columnName + " = ?");
				idValue = value;
				continue;
			}
			
			//如果是普通列
			params.add(value);
			
			if(count!=0){
				updateSql.append(",");
			}
			updateSql.append(" " + columnName + " = ?");
			
			count++;
		}
		
		updateSql.append(" where ");
		updateSql.append(whereSql);
		params.add(idValue);
		
		SqlParamsPairs sqlAndParams = new SqlParamsPairs(updateSql.toString(),params.toArray());
		logger.debug(sqlAndParams.toString());
		
		return sqlAndParams;
		
	}
928994
public static <T> Predicate<T> memoizePredicate(final Predicate<T> p, final Cacheable<Boolean> cache) {
        final Function<T, Boolean> memoised = memoizeFunction((Function<T, Boolean>) t -> p.test(t), cache);
        LazyImmutable<Boolean> nullR = LazyImmutable.def();
        return (t) -> t==null? nullR.computeIfAbsent(()->p.test(null)) : memoised.apply(t);
    }
570987
private void initJavaClassCache(Class clazz) {
        String clazzName = clazz.getName();
        Class cl = classCache.get(clazzName);
        if (null == cl) {
            synchronized (clazz) { // 进行锁控制
                cl = classCache.get(clazzName); // double check
                if (cl != null) {
                    return;
                }
                Method[] methods = clazz.getMethods();
                for (Method m : methods) {
                    String key = buildMethodKey(clazzName, m.getName(), m.getParameterTypes());
                    methodCache.put(key, m);
                }
                allMethodCache.put(clazzName, methods);
            }
        }
    }
182466
private static CacheProvider getCacheProvider(Method javaMethod) {
        if (!javaMethod.isAnnotationPresent(Cache.class)) {
            return null;
        }

        Cache an = javaMethod.getAnnotation(Cache.class);
        Class<? extends CacheProvider> cacheClazz = an.value();

        try {
            Constructor<? extends CacheProvider> constructor = cacheClazz.getDeclaredConstructor();
            constructor.setAccessible(true);
            return constructor.newInstance();
        } catch (Exception e) {
            throw new EventsException("Cannot instantiate cache provider "
                    + cacheClazz.getSimpleName() + " for method "
                    + Utils.methodToString(javaMethod), e);
        }
    }
545208
@Override
  public final IProcessor lazyGet(//NOPMD
    final Map<String, Object> pAddParam,
      final String pBeanName) throws Exception {
    IProcessor proc = this.processorsMap.get(pBeanName);
    if (proc == null) {
      // locking:
      synchronized (this.processorsMap) {
        // make sure again whether it's null after locking:
        proc = this.processorsMap.get(pBeanName);
        if (proc == null) {
          if (pBeanName.equals(PrcDelItemFromCart.class.getSimpleName())) {
            proc = lazyGetPrcDelItemFromCart(pAddParam);
          } else if (pBeanName.equals(PrCart.class.getSimpleName())) {
            proc = lazyGetPrCart(pAddParam);
          } else if (pBeanName.equals(PrcItemInCart.class.getSimpleName())) {
            proc = lazyGetPrcItemInCart(pAddParam);
          } else if (pBeanName.equals(PrLog.class.getSimpleName())) {
            proc = lazyGetPrLog(pAddParam);
          } else if (pBeanName.equals(PrcCheckOut.class.getSimpleName())) {
            proc = lazyGetPrcCheckOut(pAddParam);
          } else if (pBeanName.equals(PrBuOr.class.getSimpleName())) {
            proc = lazyGetPrBuOr(pAddParam);
          } else if (pBeanName.equals(PrBur.class.getSimpleName())) {
            proc = lazyGetPrBur(pAddParam);
          } else if (pBeanName.equals(PrPur.class.getSimpleName())) {
            proc = lazyGetPrPur(pAddParam);
          } else if (pBeanName.equals(PrcItemPage.class.getSimpleName())) {
            proc = lazyGetPrcItemPage(pAddParam);
          } else if (pBeanName.equals(PrcWebstorePage.class.getSimpleName())) {
            proc = lazyGetPrcWebstorePage(pAddParam);
          }
        }
      }
    }
    if (proc == null) {
      throw new ExceptionWithCode(ExceptionWithCode.CONFIGURATION_MISTAKE,
        "There is no processor with name " + pBeanName);
    }
    return proc;
  }
762664
@Override
	public void cacheResult(CommerceOrderPayment commerceOrderPayment) {
		entityCache.putResult(CommerceOrderPaymentModelImpl.ENTITY_CACHE_ENABLED,
			CommerceOrderPaymentImpl.class,
			commerceOrderPayment.getPrimaryKey(), commerceOrderPayment);

		commerceOrderPayment.resetOriginalValues();
	}
1065677
@Override
    public <T> T loadDataFromCache(Class<T> clazz, Object cacheKey, long maxTimeInCacheBeforeExpiry) throws CacheLoadingException, CacheCreationException {
        return getObjectPersister(clazz).loadDataFromCache(cacheKey, maxTimeInCacheBeforeExpiry);
    }
588810
@Override
    public Cache getCache(String cacheName) throws CacheException
    {
        if (this.cache == null)
        {
            this.cache = createCache(cacheName);
        }

        return this.cache;
    }
1302387
function cacher(f, scope, postprocessor) {
            function repush(array, item) {
                for (var i = 0, ii = array.length; i < ii; i++) if (array[i] === item) {
                    return array.push(array.splice(i, 1)[0]);
                }
            }
            function newf() {
                var arg = Array.prototype.slice.call(arguments, 0), args = arg.join("␀"), cache = newf.cache = newf.cache || {}, count = newf.count = newf.count || [];
                if (cache.hasOwnProperty(args)) {
                    repush(count, args);
                    return postprocessor ? postprocessor(cache[args]) : cache[args];
                }
                if (count.length >= 1e3) {
                    delete cache[count.shift()];
                }
                count.push(args);
                cache[args] = f.apply(scope, arg);
                return postprocessor ? postprocessor(cache[args]) : cache[args];
            }
            return newf;
        }
1119755
private void persistCache(String projectName, String projectVersion, Map<String, String> cache) {
		File cacheFile = new File(getCacheDir(), projectName + "/" + projectVersion);
		ObjectOutputStream oos = null;
		try {
			oos = new ObjectOutputStream(new FileOutputStream(cacheFile));
			oos.writeObject(cache);
		}
		catch (IOException ioe) {
			LOGGER.warn("Unable to create the cache file {}/{}/{}", getCacheDir().getAbsoluteFile(), projectName, projectVersion);
		}
		finally { if (oos != null) { try { oos.close(); } catch (IOException ioe) {} } }
	}
162899
void notifyConsumer(Map<String, ProviderGroup> newCache) {
        Map<String, ProviderGroup> oldCache = memoryCache;
        // 比较两个map的差异
        MapDifference<String, ProviderGroup> difference =
                new MapDifference<String, ProviderGroup>(newCache, oldCache);
        // 新的有，旧的没有，通知
        Map<String, ProviderGroup> onlynew = difference.entriesOnlyOnLeft();
        for (Map.Entry<String, ProviderGroup> entry : onlynew.entrySet()) {
            notifyConsumerListeners(entry.getKey(), entry.getValue());
        }
        // 旧的有，新的没有，全部干掉
        Map<String, ProviderGroup> onlyold = difference.entriesOnlyOnRight();
        for (Map.Entry<String, ProviderGroup> entry : onlyold.entrySet()) {
            notifyConsumerListeners(entry.getKey(), new ProviderGroup());
        }

        // 新旧都有，而且有变化
        Map<String, ValueDifference<ProviderGroup>> changed = difference.entriesDiffering();
        for (Map.Entry<String, ValueDifference<ProviderGroup>> entry : changed.entrySet()) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("{} has differente", entry.getKey());
            }
            ValueDifference<ProviderGroup> differentValue = entry.getValue();
            ProviderGroup innew = differentValue.leftValue();
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("new(right) is {}", innew);
            }
            // 只通知变化部分内容
            notifyConsumerListeners(entry.getKey(), innew);
        }
    }