aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--stage1/KeyLockedLazyCache.scala9
1 files changed, 8 insertions, 1 deletions
diff --git a/stage1/KeyLockedLazyCache.scala b/stage1/KeyLockedLazyCache.scala
index 50c6f9e..aca5f74 100644
--- a/stage1/KeyLockedLazyCache.scala
+++ b/stage1/KeyLockedLazyCache.scala
@@ -30,13 +30,20 @@ final private[cbt] class KeyLockedLazyCache[Key <: AnyRef,Value <: AnyRef](
//logger.resolver("CACHE: \n" ++ keys.mkString("\n"))
// synchronizing on key only, so asking for a particular key does
// not block the whole cache, but just that cache entry
- key.synchronized{
+ lockableKey.synchronized{
if( ! (values containsKey lockableKey) ){
values.put( lockableKey, value )
}
values get lockableKey
}
}
+ def update( key: Key, value: Value ): Value = {
+ val lockableKey = keys get key
+ lockableKey.synchronized{
+ values.put( lockableKey, value )
+ value
+ }
+ }
def remove( key: Key ) = keys.synchronized{
assert(keys containsKey key)
val lockableKey = keys get key