final
case class
Cached[+T](value: T) extends AnyVal with Product with Serializable
Instance Constructors
-
new
Cached(value: T)
Value Members
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
final
def
==(arg0: Any): Boolean
-
final
def
asInstanceOf[T0]: T0
-
def
getClass(): Class[_ <: AnyVal]
-
final
def
isInstanceOf[T0]: Boolean
-
val
value: T
Wraps a cached implicit
T.Looking for an implicit
Cached[T]first triggers a look for an implicitT, caches the resulting tree, and returns it immediately and in subsequent look ups for an implicitCached[T]. Thus, subsequent look ups do not trigger looking for an implicitT, only returning the instance kept in cache.Beware that if the contexts in which two subsequent look ups are different, so that looking for a
Tin each of them doesn't return the same result, this change would be ignored by caching. Looking for aCached[T]in the first context would put the implicitTof this context in cache, and then looking for aCached[T]in the second context would return the former instance from the first context. E.g.would print "first" then "second" (non cached
TC[Int]instances), then "first" twice (first instance, returned the second time too through the cache).