YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.util.image.ByteLruCache< K, V > Class Template Reference

A least-recently-used cache bounded by the summed size in bytes of its values, not by their number (the former thumbnail cache counted one unit per bitmap against a byte-sized limit, so it never evicted in practice). More...

Collaboration diagram for de.yaacc.util.image.ByteLruCache< K, V >:
Collaboration graph

Public Member Functions

 ByteLruCache (long maxBytes, ToLongFunction< V > sizer)
 
synchronized V get (K key)
 
synchronized void put (K key, V value)
 Stores the value as the most recently used one and evicts the least recently used ones until the limit holds.
 
synchronized void clear ()
 
synchronized int count ()
 
synchronized long bytes ()
 

Static Public Member Functions

static long defaultMaxBytes (long maxHeapBytes)
 One sixteenth of the heap, but between 8 MB and 32 MB.
 

Detailed Description

A least-recently-used cache bounded by the summed size in bytes of its values, not by their number (the former thumbnail cache counted one unit per bitmap against a byte-sized limit, so it never evicted in practice).

Thread safe; no Android classes, so the sizing function is passed in.

Member Function Documentation

◆ put()

synchronized void de.yaacc.util.image.ByteLruCache< K, V >.put ( K key,
V value )

Stores the value as the most recently used one and evicts the least recently used ones until the limit holds.

A value larger than the whole cache is not stored (and an older value for the key is dropped).

Referenced by de.yaacc.util.image.IconDownloadCacheHandler.addBitmap().

Here is the caller graph for this function:

The documentation for this class was generated from the following file: