net.sf.ehcache.Cache.loadWithRegisteredLoaders()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中net.sf.ehcache.Cache.loadWithRegisteredLoaders()方法的一些代码示例,展示了Cache.loadWithRegisteredLoaders()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.loadWithRegisteredLoaders()方法的具体详情如下:
包路径:net.sf.ehcache.Cache
类名称:Cache
方法名:loadWithRegisteredLoaders

Cache.loadWithRegisteredLoaders介绍

[英]Does the asynchronous loading.
[中]执行异步加载。

代码示例

代码示例来源:origin: net.sf.ehcache/ehcache

/**
   * Calls the CacheLoader and puts the result in the Cache
   */
  public void run() {
    try {
      Set<Object> nonLoadedKeys = new HashSet<Object>();
      for (Object key : keys) {
        if (!isKeyInCache(key)) {
          nonLoadedKeys.add(key);
        }
      }
      Map<?, ?> map = loadWithRegisteredLoaders(argument, nonLoadedKeys);
      for (Entry<?, ?> e : map.entrySet()) {
        put(new Element(e.getKey(), e.getValue()));
      }
    } catch (Throwable e) {
      if (LOG.isErrorEnabled()) {
        LOG.error("Problem during load. Load will not be completed. Cause was " + e.getCause(), e);
      }
    }
  }
});

代码示例来源:origin: net.sf.ehcache/ehcache

/**
 * Will attempt to load the value for a key, either using the passedin loader, or falling back to registered ones
 * @param key the key to load for
 * @param specificLoader the loader to use, can be null to fallback to Cache registered loaders
 * @param argument the argument to pass the loader
 * @return null if not present in the underlying SoR or if no loader available, otherwise the loaded object
 */
private Object loadValueUsingLoader(final Object key, final CacheLoader specificLoader, final Object argument) {
  Object value = null;
  if (specificLoader != null) {
    if (argument == null) {
      value = specificLoader.load(key);
    } else {
      value = specificLoader.load(key, argument);
    }
  } else if (!registeredCacheLoaders.isEmpty()) {
    value = loadWithRegisteredLoaders(argument, key);
  }
  return value;
}

代码示例来源:origin: net.sf.ehcache.internal/ehcache-core

/**
   * Calls the CacheLoader and puts the result in the Cache
   */
  public void run() {
    try {
      Set<Object> nonLoadedKeys = new HashSet<Object>();
      for (Object key : keys) {
        if (!isKeyInCache(key)) {
          nonLoadedKeys.add(key);
        }
      }
      Map<?, ?> map = loadWithRegisteredLoaders(argument, nonLoadedKeys);
      for (Entry<?, ?> e : map.entrySet()) {
        put(new Element(e.getKey(), e.getValue()));
      }
    } catch (Throwable e) {
      if (LOG.isErrorEnabled()) {
        LOG.error("Problem during load. Load will not be completed. Cause was " + e.getCause(), e);
      }
    }
  }
});

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

/**
   * Calls the CacheLoader and puts the result in the Cache
   */
  public void run() {
    try {
      Set<Object> nonLoadedKeys = new HashSet<Object>();
      for (Object key : keys) {
        if (!isKeyInCache(key)) {
          nonLoadedKeys.add(key);
        }
      }
      Map<?, ?> map = loadWithRegisteredLoaders(argument, nonLoadedKeys);
      for (Entry<?, ?> e : map.entrySet()) {
        put(new Element(e.getKey(), e.getValue()));
      }
    } catch (Throwable e) {
      if (LOG.isErrorEnabled()) {
        LOG.error("Problem during load. Load will not be completed. Cause was " + e.getCause(), e);
      }
    }
  }
});

代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache

/**
   * Calls the CacheLoader and puts the result in the Cache
   */
  public void run() {
    try {
      Set<Object> nonLoadedKeys = new HashSet<Object>();
      for (Object key : keys) {
        if (!isKeyInCache(key)) {
          nonLoadedKeys.add(key);
        }
      }
      Map<?, ?> map = loadWithRegisteredLoaders(argument, nonLoadedKeys);
      for (Entry<?, ?> e : map.entrySet()) {
        put(new Element(e.getKey(), e.getValue()));
      }
    } catch (Throwable e) {
      if (LOG.isErrorEnabled()) {
        LOG.error("Problem during load. Load will not be completed. Cause was " + e.getCause(), e);
      }
    }
  }
});

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.ehcache

/**
 * Will attempt to load the value for a key, either using the passedin loader, or falling back to registered ones
 * @param key the key to load for
 * @param specificLoader the loader to use, can be null to fallback to Cache registered loaders
 * @param argument the argument to pass the loader
 * @return null if not present in the underlying SoR or if no loader available, otherwise the loaded object
 */
private Object loadValueUsingLoader(final Object key, final CacheLoader specificLoader, final Object argument) {
  Object value = null;
  if (specificLoader != null) {
    if (argument == null) {
      value = specificLoader.load(key);
    } else {
      value = specificLoader.load(key, argument);
    }
  } else if (!registeredCacheLoaders.isEmpty()) {
    value = loadWithRegisteredLoaders(argument, key);
  }
  return value;
}

代码示例来源:origin: net.sf.ehcache.internal/ehcache-core

/**
 * Will attempt to load the value for a key, either using the passedin loader, or falling back to registered ones
 * @param key the key to load for
 * @param specificLoader the loader to use, can be null to fallback to Cache registered loaders
 * @param argument the argument to pass the loader
 * @return null if not present in the underlying SoR or if no loader available, otherwise the loaded object
 */
private Object loadValueUsingLoader(final Object key, final CacheLoader specificLoader, final Object argument) {
  Object value = null;
  if (specificLoader != null) {
    if (argument == null) {
      value = specificLoader.load(key);
    } else {
      value = specificLoader.load(key, argument);
    }
  } else if (!registeredCacheLoaders.isEmpty()) {
    value = loadWithRegisteredLoaders(argument, key);
  }
  return value;
}

代码示例来源:origin: org.sonatype.nexus.bundles/org.sonatype.nexus.bundles.ehcache

/**
 * Will attempt to load the value for a key, either using the passedin loader, or falling back to registered ones
 * @param key the key to load for
 * @param specificLoader the loader to use, can be null to fallback to Cache registered loaders
 * @param argument the argument to pass the loader
 * @return null if not present in the underlying SoR or if no loader available, otherwise the loaded object
 */
private Object loadValueUsingLoader(final Object key, final CacheLoader specificLoader, final Object argument) {
  Object value = null;
  if (specificLoader != null) {
    if (argument == null) {
      value = specificLoader.load(key);
    } else {
      value = specificLoader.load(key, argument);
    }
  } else if (!registeredCacheLoaders.isEmpty()) {
    value = loadWithRegisteredLoaders(argument, key);
  }
  return value;
}

相关文章

微信公众号

最新文章

更多

Cache类方法