RefCountedCache

mill.util.RefCountedCache
See theRefCountedCache companion object
class RefCountedCache[Key, InternalKey, InitData, Value](convertKey: Key => InternalKey, setup: (Key, InternalKey, InitData) => Value, closeValue: Value => Unit) extends AutoCloseable

Generic reference counted cache, where values are created on-demand and closed when no more references exist.

Provides a public API that uses Key, but transforms it to InternalKey for caching, usually for performance reasons.

Type parameters

InitData

transient initialization data that will be passed to setup

Attributes

Companion
object
Source
RefCountedCache.scala
Graph
Supertypes
trait AutoCloseable
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def close(): Unit

Attributes

Definition Classes
AutoCloseable
Source
RefCountedCache.scala
def get(key: Key, initData: => InitData): Value

Gets the value associated with the given key, creating a new value if necessary.

Gets the value associated with the given key, creating a new value if necessary.

Attributes

Source
RefCountedCache.scala
def release(key: Key): Option[Entry[Value]]

Reduces the reference count of the value associated with the given key. If the reference count reaches zero, the value is closed and removed from the cache.

Reduces the reference count of the value associated with the given key. If the reference count reaches zero, the value is closed and removed from the cache.

Attributes

Returns

the value with the new reference count, None if the last reference was released.

Throws
IllegalArgumentException

if the key is unknown

Source
RefCountedCache.scala