final class RefCountedCache[K, V] extends AnyRef
A lockless cache that caches values for multiple users and destroys them once all users release them. One value can be associated with many keys. Useful for sharing a costly resource.
- Alphabetic
- By Inheritance
- RefCountedCache
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
RefCountedCache(create: (K) ⇒ V, destroy: (V) ⇒ Any, keys: (K, V) ⇒ Set[K] = (_: K, _: V) => Set.empty[K])
- create
function to create new objects if not found in cache
- destroy
function to be called once the value is not used any more
- keys
function generating additional keys the value should be reachable by
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
acquire(key: K): V
Acquires a value associated with key.
Acquires a value associated with key. If the value was acquired by another thread and is present in the cache, it will be returned from cache. If the value was not found in cache, a new value will be created by invoking
create
function and will be saved to the cache and associated withkey
and other keys returned by invoking thekeys
function on the value.- Annotations
- @tailrec()
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
contains(key: K): Boolean
Returns true if cache contains given key.
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
evict(): Unit
Removes and destroys unused entries from the cache immediately.
Removes and destroys unused entries from the cache immediately. Entries with reference count > 0 are not removed.
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
release(value: V, releaseDelayMillis: Int = 0): Unit
Releases previously acquired value.
Releases previously acquired value. Once the value is released by all threads and the
releaseDelayMillis
timeout passes, the value is destroyed by callingdestroy
function and removed from the cache. -
def
shutdown(): Unit
Shuts down the background deferred
release
scheduler and forces all pending release tasks to be executed -
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()