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


Java CacheKey类代码示例

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


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

示例1: init

import com.facebook.cache.common.CacheKey; //导入依赖的package包/类
public void init(
    Resources resources,
    DeferredReleaser deferredReleaser,
    DrawableFactory animatedDrawableFactory,
    Executor uiThreadExecutor,
    MemoryCache<CacheKey, CloseableImage> memoryCache,
    @Nullable ImmutableList<DrawableFactory> drawableFactories,
    @Nullable Supplier<Boolean> debugOverlayEnabledSupplier) {
  mResources = resources;
  mDeferredReleaser = deferredReleaser;
  mAnimatedDrawableFactory = animatedDrawableFactory;
  mUiThreadExecutor = uiThreadExecutor;
  mMemoryCache = memoryCache;
  mDrawableFactories = drawableFactories;
  mDebugOverlayEnabledSupplier = debugOverlayEnabledSupplier;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:PipelineDraweeControllerFactory.java

示例2: newController

import com.facebook.cache.common.CacheKey; //导入依赖的package包/类
public PipelineDraweeController newController(
    Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier,
    String id,
    CacheKey cacheKey,
    Object callerContext,
    @Nullable ImmutableList<DrawableFactory> customDrawableFactories) {
  Preconditions.checkState(mResources != null, "init() not called");
  // Field values passed as arguments so that any subclass of PipelineDraweeControllerFactory
  // can simply override internalCreateController() and return a custom Drawee controller
  PipelineDraweeController controller = internalCreateController(
      mResources,
      mDeferredReleaser,
      mAnimatedDrawableFactory,
      mUiThreadExecutor,
      mMemoryCache,
      mDrawableFactories,
      customDrawableFactories,
      dataSourceSupplier,
      id,
      cacheKey,
      callerContext);
  if (mDebugOverlayEnabledSupplier != null) {
    controller.setDrawDebugOverlay(mDebugOverlayEnabledSupplier.get());
  }
  return controller;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:PipelineDraweeControllerFactory.java

示例3: internalCreateController

import com.facebook.cache.common.CacheKey; //导入依赖的package包/类
protected PipelineDraweeController internalCreateController(
    Resources resources,
    DeferredReleaser deferredReleaser,
    DrawableFactory animatedDrawableFactory,
    Executor uiThreadExecutor,
    MemoryCache<CacheKey, CloseableImage> memoryCache,
    @Nullable ImmutableList<DrawableFactory> globalDrawableFactories,
    @Nullable ImmutableList<DrawableFactory> customDrawableFactories,
    Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier,
    String id,
    CacheKey cacheKey,
    Object callerContext) {
  PipelineDraweeController controller = new PipelineDraweeController(
      resources,
      deferredReleaser,
      animatedDrawableFactory,
      uiThreadExecutor,
      memoryCache,
      dataSourceSupplier,
      id,
      cacheKey,
      callerContext,
      globalDrawableFactories);
  controller.setCustomDrawableFactories(customDrawableFactories);
  return controller;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:PipelineDraweeControllerFactory.java

示例4: writeToDiskCache

import com.facebook.cache.common.CacheKey; //导入依赖的package包/类
/**
 * Writes to disk cache
 * @throws IOException
 */
private void writeToDiskCache(
    final CacheKey key,
    final EncodedImage encodedImage) {
  FLog.v(TAG, "About to write to disk-cache for key %s", key.getUriString());
  try {
    mFileCache.insert(
        key, new WriterCallback() {
          @Override
          public void write(OutputStream os) throws IOException {
            mPooledByteStreams.copy(encodedImage.getInputStream(), os);
          }
        }
    );
    FLog.v(TAG, "Successful disk-cache write for key %s", key.getUriString());
  } catch (IOException ioe) {
    // Log failure
    // TODO: 3697790
    FLog.w(TAG, ioe, "Failed to write to disk-cache for key %s", key.getUriString());
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:BufferedDiskCache.java

示例5: ExperimentalBitmapAnimationDrawableFactory

import com.facebook.cache.common.CacheKey; //导入依赖的package包/类
public ExperimentalBitmapAnimationDrawableFactory(
    AnimatedDrawableBackendProvider animatedDrawableBackendProvider,
    ScheduledExecutorService scheduledExecutorServiceForUiThread,
    ExecutorService executorServiceForFramePreparing,
    MonotonicClock monotonicClock,
    PlatformBitmapFactory platformBitmapFactory,
    CountingMemoryCache<CacheKey, CloseableImage> backingCache,
    Supplier<Integer> cachingStrategySupplier,
    Supplier<Integer> numberOfFramesToPrepareSupplier) {
  mAnimatedDrawableBackendProvider = animatedDrawableBackendProvider;
  mScheduledExecutorServiceForUiThread = scheduledExecutorServiceForUiThread;
  mExecutorServiceForFramePreparing = executorServiceForFramePreparing;
  mMonotonicClock = monotonicClock;
  mPlatformBitmapFactory = platformBitmapFactory;
  mBackingCache = backingCache;
  mCachingStrategySupplier = cachingStrategySupplier;
  mNumberOfFramesToPrepareSupplier = numberOfFramesToPrepareSupplier;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:ExperimentalBitmapAnimationDrawableFactory.java

示例6: setUp

import com.facebook.cache.common.CacheKey; //导入依赖的package包/类
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  MemoryCacheParams params = new MemoryCacheParams(
      4 * ByteConstants.MB,
      256,
      Integer.MAX_VALUE,
      Integer.MAX_VALUE,
      Integer.MAX_VALUE);
  when(mMemoryCacheParamsSupplier.get()).thenReturn(params);
  CountingMemoryCache<CacheKey, CloseableImage> countingMemoryCache =
      BitmapCountingMemoryCacheFactory.get(
          mMemoryCacheParamsSupplier,
          mMemoryTrimmableRegistry,
          mPlatformBitmapFactory,
          true);
  mCacheKey = new SimpleCacheKey("key");
  mAnimatedFrameCache = new AnimatedFrameCache(mCacheKey, countingMemoryCache);
  mFrame1 = CloseableReference.of(mock(CloseableImage.class));
  mFrame2 = CloseableReference.of(mock(CloseableImage.class));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:AnimatedFrameCacheTest.java

示例7: getAnimatedFactory

import com.facebook.cache.common.CacheKey; //导入依赖的package包/类
public static AnimatedFactory getAnimatedFactory(
    PlatformBitmapFactory platformBitmapFactory,
    ExecutorSupplier executorSupplier,
    CountingMemoryCache<CacheKey, CloseableImage> backingCache) {
  if (!sImplLoaded) {
    try {
      final Class<?> clazz =
          Class.forName("com.facebook.fresco.animation.factory.AnimatedFactoryV2Impl");
      final Constructor<?> constructor = clazz.getConstructor(
          PlatformBitmapFactory.class,
          ExecutorSupplier.class,
          CountingMemoryCache.class);
      sImpl = (AnimatedFactory) constructor.newInstance(
          platformBitmapFactory,
          executorSupplier,
          backingCache);
    } catch (Throwable e) {
      // Head in the sand
    }
    if (sImpl != null) {
      sImplLoaded = true;
    }
  }
  return sImpl;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:AnimatedFactoryProvider.java

示例8: probe

import com.facebook.cache.common.CacheKey; //导入依赖的package包/类
/**
 * Probes whether the object corresponding to the mKey is in the cache.
 * Note that the act of probing touches the item (if present in cache),
 * thus changing its LRU timestamp.
 * <p>
 * This will be faster than retrieving the object, but it still has
 * file system accesses and should NOT be called on the UI thread.
 *
 * @param key the mKey to check
 * @return whether the keyed mValue is in the cache
 */
public boolean probe(final CacheKey key) {
  String resourceId = null;
  try {
    synchronized (mLock) {
      List<String> resourceIds = CacheKeyUtil.getResourceIds(key);
      for (int i = 0; i < resourceIds.size(); i++) {
        resourceId = resourceIds.get(i);
        if (mStorage.touch(resourceId, key)) {
          mResourceIndex.add(resourceId);
          return true;
        }
      }
      return false;
    }
  } catch (IOException e) {
    SettableCacheEvent cacheEvent = SettableCacheEvent.obtain()
        .setCacheKey(key)
        .setResourceId(resourceId)
        .setException(e);
    mCacheEventListener.onReadException(cacheEvent);
    cacheEvent.recycle();
    return false;
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:DiskStorageCache.java

示例9: remove

import com.facebook.cache.common.CacheKey; //导入依赖的package包/类
@Override
public void remove(CacheKey key) {
  synchronized (mLock) {
    try {
      String resourceId = null;
      List<String> resourceIds = CacheKeyUtil.getResourceIds(key);
      for (int i = 0; i < resourceIds.size(); i++) {
        resourceId = resourceIds.get(i);
        mStorage.remove(resourceId);
        mResourceIndex.remove(resourceId);
      }
    } catch (IOException e) {
      mCacheErrorLogger.logError(
          CacheErrorLogger.CacheErrorCategory.DELETE_FILE,
          TAG,
          "delete: " + e.getMessage(),
          e);
    }
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:DiskStorageCache.java

示例10: hasKey

import com.facebook.cache.common.CacheKey; //导入依赖的package包/类
@Override
public boolean hasKey(final CacheKey key) {
  synchronized (mLock) {
    if (hasKeySync(key)) {
      return true;
    }
    try {
      String resourceId = null;
      List<String> resourceIds = CacheKeyUtil.getResourceIds(key);
      for (int i = 0; i < resourceIds.size(); i++) {
        resourceId = resourceIds.get(i);
        if (mStorage.contains(resourceId, key)) {
          mResourceIndex.add(resourceId);
          return true;
        }
      }
      return false;
    } catch (IOException e) {
      return false;
    }
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:DiskStorageCache.java

示例11: getPostprocessedBitmapCacheKey

import com.facebook.cache.common.CacheKey; //导入依赖的package包/类
@Override
public CacheKey getPostprocessedBitmapCacheKey(ImageRequest request, Object callerContext) {
    final Postprocessor postprocessor = request.getPostprocessor();
    final CacheKey postprocessorCacheKey;
    final String postprocessorName;
    if (postprocessor != null) {
        postprocessorCacheKey = postprocessor.getPostprocessorCacheKey();
        postprocessorName = postprocessor.getClass().getName();
    } else {
        postprocessorCacheKey = null;
        postprocessorName = null;
    }
    return new BitmapMemoryCacheKey(
            getCacheKeySourceUri(request.getSourceUri()),
            request.getResizeOptions(),
            request.getRotationOptions(),
            request.getImageDecodeOptions(),
            postprocessorCacheKey,
            postprocessorName,
            callerContext);
}
 
开发者ID:senierr,项目名称:ModuleFrame,代码行数:22,代码来源:DefaultCacheKeyFactory.java

示例12: testConcurrency

import com.facebook.cache.common.CacheKey; //导入依赖的package包/类
/**
 * Verify that multiple threads can write to the cache at the same time.
 */
@Test
public void testConcurrency() throws Exception {
  final CyclicBarrier barrier = new CyclicBarrier(3);
  WriterCallback writerCallback = new WriterCallback() {
    @Override
    public void write(OutputStream os) throws IOException {
      try {
        // Both threads will need to hit this barrier. If writing is serialized,
        // the second thread will never reach here as the first will hold
        // the write lock forever.
        barrier.await(10, TimeUnit.SECONDS);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  };
  CacheKey key1 = new SimpleCacheKey("concurrent1");
  CacheKey key2 = new SimpleCacheKey("concurrent2");
  Thread t1 = runInsertionInSeparateThread(key1, writerCallback);
  Thread t2 = runInsertionInSeparateThread(key2, writerCallback);
  barrier.await(10, TimeUnit.SECONDS);
  t1.join(1000);
  t2.join(1000);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:DiskStorageCacheTest.java

示例13: runInsertionInSeparateThread

import com.facebook.cache.common.CacheKey; //导入依赖的package包/类
private Thread runInsertionInSeparateThread(final CacheKey key,
    final WriterCallback callback) {
  Runnable runnable = new Runnable() {

    @Override
    public void run() {
      try {
        mCache.insert(key, callback);
      } catch (IOException e) {
        fail();
      }
    }
  };
  Thread thread = new Thread(runnable);
  thread.setDaemon(true);
  thread.start();
  return thread;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:DiskStorageCacheTest.java

示例14: onNewResultImpl

import com.facebook.cache.common.CacheKey; //导入依赖的package包/类
@Override
public void onNewResultImpl(EncodedImage newResult, @Status int status) {
  // intermediate, null or uncacheable results are not cached, so we just forward them
  if (isNotLast(status) || newResult == null ||
      statusHasAnyFlag(status, DO_NOT_CACHE_ENCODED | IS_PARTIAL_RESULT)) {
    getConsumer().onNewResult(newResult, status);
    return;
  }

  final ImageRequest imageRequest = mProducerContext.getImageRequest();
  final CacheKey cacheKey =
      mCacheKeyFactory.getEncodedCacheKey(imageRequest, mProducerContext.getCallerContext());

  if (imageRequest.getCacheChoice() == ImageRequest.CacheChoice.SMALL) {
    mSmallImageBufferedDiskCache.put(cacheKey, newResult);
  } else {
    mDefaultBufferedDiskCache.put(cacheKey, newResult);
  }

  getConsumer().onNewResult(newResult, status);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:DiskCacheWriteProducer.java

示例15: verifyListenerOnWriteSuccessAndGetResourceId

import com.facebook.cache.common.CacheKey; //导入依赖的package包/类
private String verifyListenerOnWriteSuccessAndGetResourceId(
    CacheKey key,
    long itemSize) {
  ArgumentCaptor<CacheEvent> cacheEventCaptor = ArgumentCaptor.forClass(CacheEvent.class);
  mCacheEventListenerInOrder.verify(mCacheEventListener)
      .onWriteSuccess(cacheEventCaptor.capture());

  CacheEvent cacheEvent = cacheEventCaptor.getValue();
  CacheEventAssert.assertThat(cacheEvent)
      .isNotNull()
      .hasCacheKey(key)
      .hasItemSize(itemSize)
      .hasResourceIdSet();

  return cacheEvent.getResourceId();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:DiskStorageCacheTest.java


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