diff options
Diffstat (limited to 'src/scala/spark/WeakReferenceCache.scala')
-rw-r--r-- | src/scala/spark/WeakReferenceCache.scala | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/scala/spark/WeakReferenceCache.scala b/src/scala/spark/WeakReferenceCache.scala new file mode 100644 index 0000000000..ddca065454 --- /dev/null +++ b/src/scala/spark/WeakReferenceCache.scala @@ -0,0 +1,14 @@ +package spark + +import com.google.common.collect.MapMaker + +/** + * An implementation of Cache that uses weak references. + */ +class WeakReferenceCache extends Cache { + val map = new MapMaker().weakValues().makeMap[Any, Any]() + + override def get(key: Any): Any = map.get(key) + override def put(key: Any, value: Any) = map.put(key, value) +} + |