com.wavesenterprise.utils.Caches.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of we-utils Show documentation
Show all versions of we-utils Show documentation
Library for Waves Enterprise blockchain platform
package com.wavesenterprise.utils
import com.google.common.cache.{CacheBuilder, CacheLoader, LoadingCache}
object Caches {
def cache[K <: AnyRef, V <: AnyRef](maximumSize: Int, loader: K => V): LoadingCache[K, V] =
CacheBuilder
.newBuilder()
.maximumSize(maximumSize)
.build(new CacheLoader[K, V] {
override def load(key: K) = loader(key)
})
}