当前位置: 首页>>代码示例>>Java>>正文


Java LoadingCache类代码示例

本文整理汇总了Java中com.google.common.cache.LoadingCache的典型用法代码示例。如果您正苦于以下问题:Java LoadingCache类的具体用法?Java LoadingCache怎么用?Java LoadingCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LoadingCache类属于com.google.common.cache包,在下文中一共展示了LoadingCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createFilesCache

import com.google.common.cache.LoadingCache; //导入依赖的package包/类
private LoadingCache<Integer, Bucket> createFilesCache(final MinebdConfig config) {
    Preconditions.checkNotNull(config.parentDirs);
    final Integer maxOpenFiles = config.maxOpenFiles;
    Preconditions.checkNotNull(maxOpenFiles);
    Preconditions.checkArgument(maxOpenFiles > 0);
    return CacheBuilder.newBuilder()
            .maximumSize(maxOpenFiles)
            .removalListener((RemovalListener<Integer, Bucket>) notification -> {
                logger.debug("no longer monitoring bucket {}", notification.getKey());
                try {
                    notification.getValue().close();
                } catch (IOException e) {
                    logger.warn("unable to flush and close file " + notification.getKey(), e);
                }
            })
            .build(new CacheLoader<Integer, Bucket>() {
                @Override
                public Bucket load(Integer key) throws Exception {
                    return bucketFactory.create(key);
                }
            });
}
 
开发者ID:MineboxOS,项目名称:minebox,代码行数:23,代码来源:MineboxExport.java

示例2: casEventRepository

import com.google.common.cache.LoadingCache; //导入依赖的package包/类
@Bean
public CasEventRepository casEventRepository() {
    final LoadingCache<String, CasEvent> storage = CacheBuilder.newBuilder()
            .initialCapacity(INITIAL_CACHE_SIZE)
            .maximumSize(MAX_CACHE_SIZE)
            .recordStats()
            .expireAfterWrite(EXPIRATION_TIME, TimeUnit.HOURS)
            .build(new CacheLoader<String, CasEvent>() {
                @Override
                public CasEvent load(final String s) throws Exception {
                    LOGGER.error("Load operation of the cache is not supported.");
                    return null;
                }
            });
    LOGGER.debug("Created an in-memory event repository to store CAS events for [{}] hours", EXPIRATION_TIME);
    return new InMemoryCasEventRepository(storage);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:18,代码来源:CasEventsInMemoryRepositoryConfiguration.java

示例3: mfaTrustEngine

import com.google.common.cache.LoadingCache; //导入依赖的package包/类
@ConditionalOnMissingBean(name = "mfaTrustEngine")
@Bean
@RefreshScope
public MultifactorAuthenticationTrustStorage mfaTrustEngine() {
    final LoadingCache<String, MultifactorAuthenticationTrustRecord> storage = CacheBuilder.newBuilder()
            .initialCapacity(INITIAL_CACHE_SIZE)
            .maximumSize(MAX_CACHE_SIZE)
            .recordStats()
            .expireAfterWrite(casProperties.getAuthn().getMfa().getTrusted().getExpiration(),
                    casProperties.getAuthn().getMfa().getTrusted().getTimeUnit())
            .build(new CacheLoader<String, MultifactorAuthenticationTrustRecord>() {
                @Override
                public MultifactorAuthenticationTrustRecord load(final String s) throws Exception {
                    LOGGER.error("Load operation of the cache is not supported.");
                    return null;
                }
            });

    final InMemoryMultifactorAuthenticationTrustStorage m = new InMemoryMultifactorAuthenticationTrustStorage(storage);
    m.setCipherExecutor(mfaTrustCipherExecutor());
    return m;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:23,代码来源:MultifactorAuthnTrustConfiguration.java

示例4: checkPatternAt

import com.google.common.cache.LoadingCache; //导入依赖的package包/类
/**
 * checks that the given pattern & rotation is at the block co-ordinates.
 */
@Nullable
private BlockPattern.PatternHelper checkPatternAt(BlockPos pos, EnumFacing finger, EnumFacing thumb, LoadingCache<BlockPos, BlockWorldState> lcache)
{
    for (int i = 0; i < this.palmLength; ++i)
    {
        for (int j = 0; j < this.thumbLength; ++j)
        {
            for (int k = 0; k < this.fingerLength; ++k)
            {
                if (!this.blockMatches[k][j][i].apply(lcache.getUnchecked(translateOffset(pos, finger, thumb, i, j, k))))
                {
                    return null;
                }
            }
        }
    }

    return new BlockPattern.PatternHelper(pos, finger, thumb, lcache, this.palmLength, this.thumbLength, this.fingerLength);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:23,代码来源:BlockPattern.java

示例5: checkPatternAt

import com.google.common.cache.LoadingCache; //导入依赖的package包/类
/**
 * checks that the given pattern & rotation is at the block co-ordinates.
 */
private BlockPattern.PatternHelper checkPatternAt(BlockPos pos, EnumFacing finger, EnumFacing thumb, LoadingCache<BlockPos, BlockWorldState> lcache)
{
    for (int i = 0; i < this.palmLength; ++i)
    {
        for (int j = 0; j < this.thumbLength; ++j)
        {
            for (int k = 0; k < this.fingerLength; ++k)
            {
                if (!this.blockMatches[k][j][i].apply(lcache.getUnchecked(translateOffset(pos, finger, thumb, i, j, k))))
                {
                    return null;
                }
            }
        }
    }

    return new BlockPattern.PatternHelper(pos, finger, thumb, lcache, this.palmLength, this.thumbLength, this.fingerLength);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:22,代码来源:BlockPattern.java

示例6: get

import com.google.common.cache.LoadingCache; //导入依赖的package包/类
@Override
public synchronized Optional<V> get(@NonNull String key)
{
	checkNotNull(key);

	LoadingCache<String, Optional<ExpiringValue<V>>> c = cache.getIfPresent(CurrentInstitution.get());
	if( c != null )
	{
		Optional<ExpiringValue<V>> op = c.getUnchecked(key);
		if( op.isPresent() )
		{
			V ev = op.get().getValue();
			return Optional.fromNullable(ev);
		}
	}
	return Optional.absent();
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:ReplicatedCacheServiceImpl.java

示例7: getMetadata

import com.google.common.cache.LoadingCache; //导入依赖的package包/类
@Override
public Map<String, Map<String, String>> getMetadata(File f)
{
	LoadingCache<String, Map<String, String>> metadata = CacheBuilder.newBuilder().build(
		CacheLoader.from(new Function<String, Map<String, String>>()
	{
		@Override
		public Map<String, String> apply(String input)
		{
			return Maps.newHashMap();
		}
	}));
	
	for( MetadataHandler handler : pluginTracker.getBeanList() )
	{
		handler.getMetadata(metadata, f);
	}

	return metadata.asMap();
}
 
开发者ID:equella,项目名称:Equella,代码行数:21,代码来源:MetadataServiceImpl.java

示例8: isPublic

import com.google.common.cache.LoadingCache; //导入依赖的package包/类
/**
 * Returns a boolean to denote whether a cache file is visible to all (public)
 * or not
 *
 * @return true if the path in the current path is visible to all, false
 * otherwise
 */
@Private
public static boolean isPublic(FileSystem fs, Path current, FileStatus sStat,
    LoadingCache<Path,Future<FileStatus>> statCache) throws IOException {
  current = fs.makeQualified(current);
  //the leaf level file should be readable by others
  if (!checkPublicPermsForAll(fs, sStat, FsAction.READ_EXECUTE, FsAction.READ)) {
    return false;
  }

  if (Shell.WINDOWS && fs instanceof LocalFileSystem) {
    // Relax the requirement for public cache on LFS on Windows since default
    // permissions are "700" all the way up to the drive letter. In this
    // model, the only requirement for a user is to give EVERYONE group
    // permission on the file and the file will be considered public.
    // This code path is only hit when fs.default.name is file:/// (mainly
    // in tests).
    return true;
  }
  return ancestorsHaveExecutePermissions(fs, current.getParent(), statCache);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:FSDownload.java

示例9: handleInitContainerResources

import com.google.common.cache.LoadingCache; //导入依赖的package包/类
/**
 * For each of the requested resources for a container, determines the
 * appropriate {@link LocalResourcesTracker} and forwards a 
 * {@link LocalResourceRequest} to that tracker.
 */
private void handleInitContainerResources(
    ContainerLocalizationRequestEvent rsrcReqs) {
  Container c = rsrcReqs.getContainer();
  // create a loading cache for the file statuses
  LoadingCache<Path,Future<FileStatus>> statCache =
      CacheBuilder.newBuilder().build(FSDownload.createStatusCacheLoader(getConfig()));
  LocalizerContext ctxt = new LocalizerContext(
      c.getUser(), c.getContainerId(), c.getCredentials(), statCache);
  Map<LocalResourceVisibility, Collection<LocalResourceRequest>> rsrcs =
    rsrcReqs.getRequestedResources();
  for (Map.Entry<LocalResourceVisibility, Collection<LocalResourceRequest>> e :
       rsrcs.entrySet()) {
    LocalResourcesTracker tracker =
        getLocalResourcesTracker(e.getKey(), c.getUser(),
            c.getContainerId().getApplicationAttemptId()
                .getApplicationId());
    for (LocalResourceRequest req : e.getValue()) {
      tracker.handle(new ResourceRequestEvent(req, e.getKey(), ctxt));
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:ResourceLocalizationService.java

示例10: checkPatternAt

import com.google.common.cache.LoadingCache; //导入依赖的package包/类
@Nullable

    /**
     * checks that the given pattern & rotation is at the block co-ordinates.
     */
    private BlockPattern.PatternHelper checkPatternAt(BlockPos pos, EnumFacing finger, EnumFacing thumb, LoadingCache<BlockPos, BlockWorldState> lcache)
    {
        for (int i = 0; i < this.palmLength; ++i)
        {
            for (int j = 0; j < this.thumbLength; ++j)
            {
                for (int k = 0; k < this.fingerLength; ++k)
                {
                    if (!this.blockMatches[k][j][i].apply(lcache.getUnchecked(translateOffset(pos, finger, thumb, i, j, k))))
                    {
                        return null;
                    }
                }
            }
        }

        return new BlockPattern.PatternHelper(pos, finger, thumb, lcache, this.palmLength, this.thumbLength, this.fingerLength);
    }
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:24,代码来源:BlockPattern.java

示例11: OidcIdTokenSigningAndEncryptionService

import com.google.common.cache.LoadingCache; //导入依赖的package包/类
public OidcIdTokenSigningAndEncryptionService(final LoadingCache<String, Optional<RsaJsonWebKey>> defaultJsonWebKeystoreCache,
                                              final LoadingCache<OidcRegisteredService, Optional<RsaJsonWebKey>> serviceJsonWebKeystoreCache,
                                              final String issuer) {
    this.defaultJsonWebKeystoreCache = defaultJsonWebKeystoreCache;
    this.serviceJsonWebKeystoreCache = serviceJsonWebKeystoreCache;
    this.issuer = issuer;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:8,代码来源:OidcIdTokenSigningAndEncryptionService.java

示例12: oidcServiceJsonWebKeystoreCache

import com.google.common.cache.LoadingCache; //导入依赖的package包/类
@Bean
public LoadingCache<OidcRegisteredService, Optional<RsaJsonWebKey>> oidcServiceJsonWebKeystoreCache() {
    final OidcProperties oidc = casProperties.getAuthn().getOidc();
    final LoadingCache<OidcRegisteredService, Optional<RsaJsonWebKey>> cache =
            CacheBuilder.newBuilder().maximumSize(1)
                    .expireAfterWrite(oidc.getJwksCacheInMinutes(), TimeUnit.MINUTES)
                    .build(oidcServiceJsonWebKeystoreCacheLoader());
    return cache;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:10,代码来源:OidcConfiguration.java

示例13: oidcDefaultJsonWebKeystoreCache

import com.google.common.cache.LoadingCache; //导入依赖的package包/类
@Bean
public LoadingCache<String, Optional<RsaJsonWebKey>> oidcDefaultJsonWebKeystoreCache() {
    final OidcProperties oidc = casProperties.getAuthn().getOidc();
    final LoadingCache<String, Optional<RsaJsonWebKey>> cache =
            CacheBuilder.newBuilder().maximumSize(1)
                    .expireAfterWrite(oidc.getJwksCacheInMinutes(), TimeUnit.MINUTES)
                    .build(oidcDefaultJsonWebKeystoreCacheLoader());
    return cache;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:10,代码来源:OidcConfiguration.java

示例14: PatternHelper

import com.google.common.cache.LoadingCache; //导入依赖的package包/类
public PatternHelper(BlockPos posIn, EnumFacing fingerIn, EnumFacing thumbIn, LoadingCache<BlockPos, BlockWorldState> lcacheIn, int p_i46378_5_, int p_i46378_6_, int p_i46378_7_)
{
    this.frontTopLeft = posIn;
    this.forwards = fingerIn;
    this.up = thumbIn;
    this.lcache = lcacheIn;
    this.width = p_i46378_5_;
    this.height = p_i46378_6_;
    this.depth = p_i46378_7_;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:11,代码来源:BlockPattern.java

示例15: createCache

import com.google.common.cache.LoadingCache; //导入依赖的package包/类
private static <T> LoadingCache<Class<T>, AtomicInteger> createCache(
    Class<T> klass) {
  return CacheBuilder.newBuilder().build(
      new CacheLoader<Class<T>, AtomicInteger>() {
        @Override
        public AtomicInteger load(Class<T> key) throws Exception {
          return new AtomicInteger();
        }
      });
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:11,代码来源:CodecPool.java


注:本文中的com.google.common.cache.LoadingCache类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。