T - is the class of object to store in cache.public class Builder<T>
extends java.lang.Object
| Constructor and Description |
|---|
Builder(java.lang.String id,
int appVersion)
Start the building of the cache.
|
| Modifier and Type | Method and Description |
|---|---|
DualCache<T> |
build()
Builder the cache.
|
Builder<T> |
enableLog()
Enabling log from the cache.
|
Builder<T> |
noDisk()
Use this if you do not want use the disk cache layer, meaning that only the ram cache layer
will be used.
|
Builder<T> |
noRam()
The ram cache will not be used, meaning that only the disk cache will be used.
|
Builder<T> |
useReferenceInRam(int maxRamSizeBytes,
SizeOf<T> handlerSizeOf)
Store directly objects in ram (without serialization/deserialization).
|
Builder<T> |
useSerializerInDisk(int maxDiskSizeBytes,
boolean usePrivateFiles,
<any> serializer,
android.content.Context context)
Use custom serialization/deserialization to store and retrieve objects from disk cache.
|
Builder<T> |
useSerializerInDisk(int maxDiskSizeBytes,
java.io.File diskCacheFolder,
<any> serializer)
Use custom serialization/deserialization to store and retrieve object from disk cache.
|
Builder<T> |
useSerializerInRam(int maxRamSizeBytes,
<any> serializer)
Use Json serialization/deserialization to store and retrieve object from ram cache.
|
public Builder(java.lang.String id,
int appVersion)
id - is the id of the cache (should be unique).appVersion - is the app version of the app. If data are already stored in disk cache
with previous app version, it will be invalidate.public Builder<T> enableLog()
public DualCache<T> build()
public Builder<T> useSerializerInRam(int maxRamSizeBytes, <any> serializer)
maxRamSizeBytes - is the max amount of ram in bytes which can be used by the ram cache.serializer - is the cache interface which provide serialization/deserialization
methods
for the ram cache layer.public Builder<T> useReferenceInRam(int maxRamSizeBytes, SizeOf<T> handlerSizeOf)
maxRamSizeBytes - is the max amount of ram which can be used by the ram cache.handlerSizeOf - computes the size of object stored in ram.public Builder<T> noRam()
public Builder<T> useSerializerInDisk(int maxDiskSizeBytes, boolean usePrivateFiles, <any> serializer, android.content.Context context)
maxDiskSizeBytes - is the max size of disk in bytes which an be used by the disk cache
layer.usePrivateFiles - is true if you want to use Context.MODE_PRIVATE with the
default disk cache folder.serializer - provides serialization/deserialization methods for the disk cache
layer.context - is used to access file system.public Builder<T> useSerializerInDisk(int maxDiskSizeBytes, java.io.File diskCacheFolder, <any> serializer)
maxDiskSizeBytes - is the max size of disk in bytes which an be used by the disk cache
layer.diskCacheFolder - is the folder where the disk cache will be stored.serializer - provides serialization/deserialization methods for the disk cache
layer.