Skip to content

Instantly share code, notes, and snippets.

@bandrzejczak
Created February 9, 2018 22:23
Show Gist options
  • Save bandrzejczak/6f51abc6ed693d7334f10519b9c90ca6 to your computer and use it in GitHub Desktop.
Save bandrzejczak/6f51abc6ed693d7334f10519b9c90ca6 to your computer and use it in GitHub Desktop.
import scalacache._
import scala.concurrent.ExecutionContext.Implicits.global
import scalacache.modes.scalaFuture._
implicit val cache: Cache[Token] = ???
def obtainTokenFor(userId: String): Future[(Token, Duration)] = ???
val userId = "123"
cachingWithTTL(userId)(obtainTokenFor(userId)) // yields Future[Token]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment