-
Notifications
You must be signed in to change notification settings - Fork 1
@CacheKey annotation
crypticminds edited this page Feb 5, 2020
·
3 revisions
@CacheKey annotation is used along with @Freeze or @Refrigerate to define which method parameter will form the key for the cache.
@Refrigerate
fun someMethodToDownloadText(@CacheKey val argument1 : String,
@CacheKey val argument2 : String,
val argument3 : String) : String {
// method logic
}@Freeze
Class cacheClass {
fun someMethodToDownloadText(@CacheKey val argument1 : String,
@CacheKey val argument2 : String,
val argument3 : String) : String{
// method logic
}
}ColdStorage will cache the output of the function where the key of the cache will be
argument1.hashCode().toString() + argument2.hashCode().toString()It is important to note the any object declared as a cache key should have a hashCode implementation
If no cache key is defined for a method, then all the fields of the method will together form the key of the cache for that method.