put

fun <T> put(proxy: T): T(source)

Adds a T instance to the cache and attaches a toggle reference.

  • If the object is floating, it is sunk (refSink()).

  • A toggle reference is added and the object is unreferenced.

  • A Cleaner ensures proper removal when the object is GC'ed.

Return

The existing or newly added instance.

Parameters

T

The type of the instance being cached.

proxy

The instance to be cached.