Package com.bumptech.glide.load.model
Class ModelCache<A,B>
- java.lang.Object
-
- com.bumptech.glide.load.model.ModelCache<A,B>
-
- Type Parameters:
A- Some Model type that implementsObject.equals(java.lang.Object)andObject.hashCode().B- Some useful type that may be expensive to create (URL, file path, etc).
public class ModelCache<A,B> extends java.lang.ObjectA simple cache that can be used byModelLoaderandModelLoaderFactoryto cache some data for a given model, width and height. For a loader that takes a model and returns a url, the cache could be used to safely memoize url creation based on the width and height of the view.
-
-
Constructor Summary
Constructors Constructor Description ModelCache()ModelCache(long size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Removes all entries from the cache.Bget(A model, int width, int height)Get a value.voidput(A model, int width, int height, B value)Add a value.
-
-
-
Method Detail
-
get
@Nullable public B get(A model, int width, int height)
Get a value.- Parameters:
model- The model.width- The width in pixels of the view the image is being loaded into.height- The height in pixels of the view the image is being loaded into.- Returns:
- The cached result, or null.
-
put
public void put(A model, int width, int height, B value)
Add a value.- Parameters:
model- The model.width- The width in pixels of the view the image is being loaded into.height- The height in pixels of the view the image is being loaded into.value- The value to store.
-
clear
public void clear()
Removes all entries from the cache.
-
-