1

I am using glide v4 I am trying to resize the cache (default on glide is 250mb).

I do this like this:

@GlideModule
public class LimitCacheSizeGlideModule extends AppGlideModule {

@Override
public void applyOptions(@NotNull Context context, GlideBuilder builder) {
    builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_ARGB_8888));

    int memoryCacheSizeBytes = 1024 * 1024 * 100; // 100mb
    builder.setMemoryCache(new LruResourceCache(memoryCacheSizeBytes));
    Log.e(TAG, "set glide cache size");
}

@Override
public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
  Log.e(TAG, "registerComponents");
    registry.append(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory());
}

// Disable manifest parsing to avoid adding similar modules twice.
@Override
public boolean isManifestParsingEnabled() {
    return false;
}
}

But it not work . My cache size exceeds the value I specified. and my Log.e(...) not display. please help.

Farzad Kamali
  • 751
  • 2
  • 6
  • 24

0 Answers0