All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.spotify.scio.extra.sparkey.instances.CachedStringSparkeyReader.scala Maven / Gradle / Ivy

There is a newer version: 0.14.8
Show newest version
package com.spotify.scio.extra.sparkey.instances

import com.spotify.scio.util.Cache
import com.spotify.sparkey.SparkeyReader

/** A wrapper around `SparkeyReader` that includes an in-memory Caffeine cache. */
class CachedStringSparkeyReader(val sparkey: SparkeyReader, val cache: Cache[String, String])
    extends StringSparkeyReader(sparkey) {
  override def get(key: String): Option[String] =
    Option(cache.get(key, sparkey.getAsString(key)))

  def close(): Unit = {
    sparkey.close()
    cache.invalidateAll()
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy