CachedFactoryWithInitData
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
Type parameters
- InitData
-
the transient initialization data that will be passed to setup.
- K
-
the cache key. setup will be invoked if the key is not found in the cache.
- V
-
the cached value
Attributes
- Source
- CachedFactory.scala
- Graph
-
- Supertypes
-
trait AutoCloseableclass Objecttrait Matchableclass Any
- Known subtypes
Members list
Type members
Inherited types
Attributes
- Inherited from:
- CachedFactoryBase
- Source
- CachedFactoryBase.scala
Value members
Concrete methods
Returns true if the cache entry associated with the given key is still valid, false otherwise.
Returns true if the cache entry associated with the given key is still valid, false otherwise.
If false, the entry will be removed from the cache and setup will be invoked.
Attributes
- Source
- CachedFactory.scala
Returns true if the cache entry associated with the given key is still valid. If false, the entry will be removed from the cache and setup will be invoked.
Returns true if the cache entry associated with the given key is still valid. If false, the entry will be removed from the cache and setup will be invoked.
Attributes
- Definition Classes
- Source
- CachedFactory.scala
Convert the public key to an internal key used for caching.
Create a new value for the given key.
If true, a value can be used concurrently by multiple consumers (reference counted). If false, a value can only be used by one consumer at a time.
If true, a value can be used concurrently by multiple consumers (reference counted). If false, a value can only be used by one consumer at a time.
Attributes
- Source
- CachedFactory.scala
Clean up a value when it is evicted from the cache.
Inherited methods
Attributes
- Definition Classes
-
CachedFactoryBase -> AutoCloseable
- Inherited from:
- CachedFactoryBase
- Source
- CachedFactoryBase.scala
Get a value for the given key, creating one if necessary. The caller must call release when done with the value.
Get a value for the given key, creating one if necessary. The caller must call release when done with the value.
Attributes
- Inherited from:
- CachedFactoryBase
- Source
- CachedFactoryBase.scala
Release a reference to the value associated with the given key. If this was the last reference, the value moves to the unused cache.
Release a reference to the value associated with the given key. If this was the last reference, the value moves to the unused cache.
Attributes
- Returns
-
Some(entry) if there are still active references (only possible in shared mode), None otherwise
- Inherited from:
- CachedFactoryBase
- Source
- CachedFactoryBase.scala
Release a reference to a specific value, matching by value identity. This should be used when shareValues = false and multiple entries may have the same key.
Release a reference to a specific value, matching by value identity. This should be used when shareValues = false and multiple entries may have the same key.
Attributes
- Inherited from:
- CachedFactoryBase
- Source
- CachedFactoryBase.scala
Get a value, use it in the provided block, then release it.
Get a value, use it in the provided block, then release it.
Attributes
- Inherited from:
- CachedFactoryBase
- Source
- CachedFactoryBase.scala
Inherited and Abstract methods
Maximum number of unused values to keep in the LRU cache. Set to 0 to disable caching of unused values (values are closed immediately when released).
Maximum number of unused values to keep in the LRU cache. Set to 0 to disable caching of unused values (values are closed immediately when released).
Attributes
- Inherited from:
- CachedFactoryBase
- Source
- CachedFactoryBase.scala