Skip to content

Instantly share code, notes, and snippets.

@ericacm
Created August 25, 2012 17:19
Show Gist options
  • Save ericacm/3468129 to your computer and use it in GitHub Desktop.
Save ericacm/3468129 to your computer and use it in GitHub Desktop.
Auto Updating Caching System - Service1CacheActor.scala
class Service1CacheActor(val cache: Cache, cacheSystem: CacheSystem,
bizService: BusinessService)
extends DateCacheActor[JList[Service1Result]](cacheSystem) {
override def receive = super.receive
override def updateCacheForDate(date: Date) {
import DateCacheActor._
Future { findObject(new Service1Params(date, true)) }
Future { findObject(new Service1Params(date, false)) }
}
def finder(params: Params) = { () =>
params match {
case p: Service1Params => bizService.service1(p.date, p.useFoo)
case _ => throw new IllegalArgumentException("...")
}
}
}
class Service1Params(date: Date, val useFoo: Boolean)
extends DateParams(date) {
override def cacheKey = super.cacheKey + ":" + useFoo
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment