CachedFactory

mill.util.CachedFactory
@Scaladoc(value = "/**\n * Manage the setup, teardown, and caching of objects of type [[V]] safely\n * in a multithreaded environment.\n *\n * The user provides the [[setup]] and [[teardown]] logic along with a [[maxCacheSize]],\n * and [[CachedFactory]] provides instances of [[V]] as requested using the [[withValue]]\n * method. These instances are automatically constructed on-demand from the give key,\n * cached with an LRU strategy, and destroyed when they are eventually evicted\n *\n * Intended for relatively small caches approximately O(num-threads) in size that\n * will typically get used in a build system, not intended for caching large amounts of entries\n */")
abstract class CachedFactory[K, V] extends AutoCloseable

Manage the setup, teardown, and caching of objects of type V safely in a multithreaded environment.

The user provides the setup and teardown logic along with a maxCacheSize, and CachedFactory provides instances of V as requested using the withValue method. These instances are automatically constructed on-demand from the give key, cached with an LRU strategy, and destroyed when they are eventually evicted

Intended for relatively small caches approximately O(num-threads) in size that will typically get used in a build system, not intended for caching large amounts of entries

Attributes

Source
CachedFactory.scala
Graph
Supertypes
trait AutoCloseable
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def maxCacheSize: Int

Attributes

Source
CachedFactory.scala
def setup(key: K): V

Attributes

Source
CachedFactory.scala
def teardown(key: K, value: V): Unit

Attributes

Source
CachedFactory.scala

Concrete methods

def close(): Unit

Attributes

Source
CachedFactory.scala
def withValue[R](key: K)(block: V => R): R

Attributes

Source
CachedFactory.scala