當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。