LruCacheKt
public final class LruCacheKt
Summary
Public methods |
|
|---|---|
static final @NonNull LruCache<@NonNull K, @NonNull V> |
<K extends Object, V extends Object> lruCache(Creates an |
Public methods
lruCache
public static final @NonNull LruCache<@NonNull K, @NonNull V> <K extends Object, V extends Object> lruCache(
int maxSize,
@NonNull Function2<@NonNull key, @NonNull value, @NonNull Integer> sizeOf,
@NonNull Function1<@NonNull key, V> create,
@NonNull Function4<@NonNull Boolean, @NonNull key, @NonNull oldValue, newValue, Unit> onEntryRemoved
)
Creates an LruCache with the given parameters.
| Parameters | |
|---|---|
int maxSize |
for caches that do not specify |
@NonNull Function2<@NonNull key, @NonNull value, @NonNull Integer> sizeOf |
function that returns the size of the entry for key and value in user-defined units. The default implementation returns 1. |
@NonNull Function1<@NonNull key, V> create |
a create called after a cache miss to compute a value for the corresponding key. Returns the computed value or null if no value can be computed. The default implementation returns null. |
@NonNull Function4<@NonNull Boolean, @NonNull key, @NonNull oldValue, newValue, Unit> onEntryRemoved |
a function called for entries that have been evicted or removed. |
| See also | |
|---|---|
sizeOf |
|
create |
|
entryRemoved |