Implemented switching of cache provider: InMemory, Redis - fixed ttl=0 issue in case of Redis

This commit is contained in:
constantine2nd 2018-05-11 13:42:15 +02:00
parent e4fdd1c1c0
commit ef8e2729ae

View File

@ -9,8 +9,10 @@ import scala.language.postfixOps
object Caching {
def memoizeSyncWithProvider[A](unique: Option[String])(ttl: Duration)(f: => A)(implicit m: Manifest[A]): A = {
unique match {
case Some(_) => // Caching a call
(unique, ttl) match {
case (_, t) if t == Duration.Zero => // Just forwarding a call
f
case (Some(_), _) => // Caching a call
APIUtil.getPropsValue("guava.cache") match {
case Full(value) if value.toLowerCase == "redis" =>
Redis.memoizeSyncWithRedis(unique)(ttl)(f)