-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
target/ | ||
/.lib/ | ||
|
||
*~ | ||
/.ensime | ||
|
||
/.cache | ||
/.classpath | ||
/.project | ||
/.settings/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# spray |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* basic project info */ | ||
name := "test" | ||
|
||
organization := "test" | ||
|
||
version := "0.1" | ||
|
||
description := "test" | ||
|
||
startYear := Some(2012) | ||
|
||
/* scala versions and options */ | ||
scalaVersion := "2.10.0-RC3" | ||
|
||
// crossScalaVersions := Seq("2.9.1") | ||
|
||
offline := false | ||
|
||
scalacOptions ++= Seq("-deprecation", "-unchecked") | ||
|
||
// scalacOptions ++= Seq("-Ydependent-method-types") // if using shapeless | ||
|
||
javacOptions ++= Seq("-Xlint:unchecked", "-Xlint:deprecation") | ||
|
||
mainClass in (Compile, run) := Some("test.Main") | ||
|
||
/* dependencies */ | ||
libraryDependencies ++= Seq ( | ||
"io.spray" % "spray-io" % "1.1-M5", | ||
"io.spray" % "spray-caching" % "1.1-M5", | ||
"com.typesafe.akka" % "akka-actor_2.10.0-RC3" % "2.1.0-RC3" | ||
) | ||
|
||
resolvers ++= Seq( | ||
"spray repo" at "http://repo.spray.io" | ||
) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sbt.version=0.12.1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import sbt._ | ||
import Keys._ | ||
|
||
object build extends Build { | ||
|
||
val gcsettings = Defaults.defaultSettings | ||
|
||
val gc = TaskKey[Unit]("gc", "runs garbage collector") | ||
val gcTask = gc := { | ||
println("requesting garbage collection") | ||
System gc() | ||
} | ||
|
||
lazy val project = Project ( | ||
"project", | ||
file("."), | ||
settings = gcsettings ++ Seq(gcTask) | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.8.4") | ||
|
||
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0") | ||
|
||
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.0") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package test | ||
|
||
import java.util.concurrent.TimeUnit._ | ||
|
||
import scala.concurrent.Future | ||
import scala.concurrent.duration.{ Duration } | ||
import akka.actor.ActorSystem | ||
import spray.caching.{ LruCache, Cache } | ||
import spray.util._ | ||
|
||
object Main extends App { | ||
implicit val system = ActorSystem() | ||
|
||
def expensiveOp(): Double = { | ||
Thread.sleep(500) | ||
new util.Random().nextDouble() | ||
} | ||
|
||
val cache: Cache[Double] = LruCache() | ||
|
||
def cachedOp[T](key: T): Future[Double] = cache(key) { | ||
expensiveOp() | ||
} | ||
|
||
println(cachedOp("foo").await) | ||
println(cachedOp("bar").await(Duration(100, MILLISECONDS))) | ||
|
||
system.shutdown() | ||
} |