Created
July 4, 2012 22:49
-
-
Save dt/3049932 to your computer and use it in GitHub Desktop.
Caching Webservice call wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object CachedWS { | |
def apply[T](key: String)(f: => Promise[Option[T]])(implicit m: scala.reflect.ClassManifest[T]): Promise[Option[T]] = | |
Cache.getAs[T](key).map(t => Promise.pure(Some(t))).getOrElse{f.map(_.map{ t => Cache.set(key, t); t})} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment