Skip to content

Instantly share code, notes, and snippets.

@nicmarti
Created March 1, 2013 11:27
Show Gist options
  • Save nicmarti/5064060 to your computer and use it in GitHub Desktop.
Save nicmarti/5064060 to your computer and use it in GitHub Desktop.
Play2 and Redis simple demo - How to load an Origin from a Redis data store with a for-comprehension
def getOrigin(originId: Long): Option[Origin] = Redis.pool.withClient {
client =>
for(slug<-Option(client.hget("Url:From:Rev", originId.toString));
display<-Option(client.hget("Places:Place:"+originId, "display")
)) yield Origin(originId,display,slug)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment