use of com.facebook.cache.common.CacheKey in project fresco by facebook.
the class DiskStorageCacheTest method testHasKeyWithoutPopulateAtStartupWithoutAwaitingIndex.
@Test
public void testHasKeyWithoutPopulateAtStartupWithoutAwaitingIndex() throws Exception {
CacheKey key = putOneThingInCache();
// A new cache object in the same directory. Equivalent to a process restart.
// Index may not yet updated.
DiskStorageCache cache2 = createDiskCache(mStorage, false);
assertTrue(cache2.isIndexReady());
assertFalse(cache2.hasKeySync(key));
assertTrue(cache2.hasKey(key));
// hasKey() adds item to the index
assertTrue(cache2.hasKeySync(key));
}
use of com.facebook.cache.common.CacheKey in project fresco by facebook.
the class DiskStorageCacheTest method testGetResourceWithoutAwaitingIndex.
@Test
public void testGetResourceWithoutAwaitingIndex() throws Exception {
CacheKey key = putOneThingInCache();
// A new cache object in the same directory. Equivalent to a process restart.
// Index may not yet updated.
DiskStorageCache cache2 = createDiskCache(mStorage, false);
assertNotNull(cache2.getResource(key));
}
use of com.facebook.cache.common.CacheKey in project fresco by facebook.
the class DefaultCacheKeyFactory method getPostprocessedBitmapCacheKey.
@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()).toString(), request.getResizeOptions(), request.getRotationOptions(), request.getImageDecodeOptions(), postprocessorCacheKey, postprocessorName, callerContext);
}
use of com.facebook.cache.common.CacheKey in project fresco by facebook.
the class DiskStorageCacheTest method testClearIndex.
@Test
public void testClearIndex() throws Exception {
CacheKey key = putOneThingInCache();
mCache.clearAll();
assertFalse(mCache.hasKeySync(key));
assertFalse(mCache.hasKey(key));
}
use of com.facebook.cache.common.CacheKey in project fresco by facebook.
the class DiskStorageCacheTest method putOneThingInCache.
private CacheKey putOneThingInCache(DiskStorageCache cache) throws IOException {
CacheKey key = new SimpleCacheKey("foo");
byte[] value1 = new byte[101];
value1[80] = 'c';
cache.insert(key, WriterCallbacks.from(value1));
return key;
}
Aggregations