mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 18:26:50 +00:00
Implemented switching of cache provider: InMemory, Redis - fixed ttl=0 issue in case of Redis
This commit is contained in:
parent
e4fdd1c1c0
commit
ef8e2729ae
6
src/main/scala/code/api/cache/Caching.scala
vendored
6
src/main/scala/code/api/cache/Caching.scala
vendored
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user