com.twitter.storehaus

cache

package cache

Visibility
  1. Public
  2. All

Type Members

  1. sealed class ApproxHHTracker[K] extends AnyRef

  2. class Atomic[T <: AnyRef] extends AnyRef

  3. trait Cache[K, V] extends AnyRef

    Immutable Cache trait for use with Storehaus stores.

    Immutable Cache trait for use with Storehaus stores.

    Inspired by clojure's core.cache: https://github.com/clojure/core.cache/blob/master/src/main/clojure/clojure/core/cache.clj

  4. trait CacheProxied[T] extends AnyRef

    Defines the base of a proxy for a given type.

    Defines the base of a proxy for a given type. A instance of Proxied for type T is intended to use the self member to forward all methods of an new instance of type T to. This allows for extensions of type T which can inherit a proxied instance's behavior without needing to override every method of type T.

    class Dazzle {
      def a: String = "default a"
      def b: String = "default b"
      // ...
    }
    
    // define a reusable concrete proxy statisfying Dazzle forwarding
    // all calls to Proxied method self
    class DazzleProxy(val self: Dazzle) extends Dazzle with Proxied[Dazzle] {
      def a: String = self.a
      def b: String = self.b
    }
    
    val bedazzlable = new Dazzle {
      // return a new Dazzle with some sizzle
      def be(sizzle: String): Dazzle = new DazzleProxy(this) {
        override def b = "%s %s!!!" format(self.b, sizzle)
      }
    }
    
    val dazzled = bedazzlable.be("dazzled")
    dazzled.b // default b dazzled!!!
    dazzled.a // default a
  5. trait Clock[T, +This <: Clock[T, This]] extends AnyRef

    A clock is anything which provides a succession of values.

  6. sealed trait CyclicIncrement[K] extends AnyRef

  7. class CyclicIncrementProvider[K] extends IdProvider[CyclicIncrement[K]]

  8. class FilteredMutableCache[K, V] extends MutableCache[K, V]

    MutableCache that applies a filter to each value.

  9. class HHFilteredCache[K, V] extends MutableCacheProxy[K, V]

  10. case class HeavyHittersPercent(toFloat: Float) extends Product with Serializable

  11. trait IdProvider[T] extends Clock[T, IdProvider[T]]

  12. class JMapCache[K, V] extends MutableCache[K, V]

    Returns a MutableCache instance backed by the supplied java.util.Map.

  13. class LIRSCache[K, V] extends Cache[K, V]

  14. class LIRSStacks[K] extends AnyRef

  15. class LRUCache[K, V] extends Cache[K, V]

  16. case class LongClock(v: Long = 0) extends Clock[Long, LongClock] with Product with Serializable

  17. class MapCache[K, V] extends Cache[K, V]

  18. class Memoize1[-T1, +R] extends (T1) ⇒ R

    Returns an instance of Function1 memoized using the supplied mutable cache.

    Returns an instance of Function1 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1) =>
         |   println("calculating!")
         |   (x1).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1)
    calculating!
    res0: String = (1)
    
    scala> memoFn(1)
    res1: String = (1)
  19. class Memoize10[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, +R] extends (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) ⇒ R

    Returns an instance of Function10 memoized using the supplied mutable cache.

    Returns an instance of Function10 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    calculating!
    res9: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    res10: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
  20. class Memoize11[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, +R] extends (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) ⇒ R

    Returns an instance of Function11 memoized using the supplied mutable cache.

    Returns an instance of Function11 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
    calculating!
    res10: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
    res11: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
  21. class Memoize12[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, +R] extends (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) ⇒ R

    Returns an instance of Function12 memoized using the supplied mutable cache.

    Returns an instance of Function12 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
    calculating!
    res11: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
    res12: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
  22. class Memoize13[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, +R] extends (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) ⇒ R

    Returns an instance of Function13 memoized using the supplied mutable cache.

    Returns an instance of Function13 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)
    calculating!
    res12: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)
    res13: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)
  23. class Memoize14[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, +R] extends (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) ⇒ R

    Returns an instance of Function14 memoized using the supplied mutable cache.

    Returns an instance of Function14 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
    calculating!
    res13: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
    res14: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
  24. class Memoize15[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, +R] extends (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) ⇒ R

    Returns an instance of Function15 memoized using the supplied mutable cache.

    Returns an instance of Function15 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
    calculating!
    res14: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
    res15: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
  25. class Memoize16[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, +R] extends (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) ⇒ R

    Returns an instance of Function16 memoized using the supplied mutable cache.

    Returns an instance of Function16 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
    calculating!
    res15: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
    res16: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
  26. class Memoize17[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, +R] extends (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) ⇒ R

    Returns an instance of Function17 memoized using the supplied mutable cache.

    Returns an instance of Function17 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)
    calculating!
    res16: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)
    res17: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)
  27. class Memoize18[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, +R] extends (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) ⇒ R

    Returns an instance of Function18 memoized using the supplied mutable cache.

    Returns an instance of Function18 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)
    calculating!
    res17: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)
    res18: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)
  28. class Memoize19[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, +R] extends (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) ⇒ R

    Returns an instance of Function19 memoized using the supplied mutable cache.

    Returns an instance of Function19 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)
    calculating!
    res18: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)
    res19: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)
  29. class Memoize2[-T1, -T2, +R] extends (T1, T2) ⇒ R

    Returns an instance of Function2 memoized using the supplied mutable cache.

    Returns an instance of Function2 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2) =>
         |   println("calculating!")
         |   (x1, x2).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2)
    calculating!
    res1: String = (1, 2)
    
    scala> memoFn(1, 2)
    res2: String = (1, 2)
  30. class Memoize20[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, -T20, +R] extends (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20) ⇒ R

    Returns an instance of Function20 memoized using the supplied mutable cache.

    Returns an instance of Function20 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
    calculating!
    res19: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
    res20: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
  31. class Memoize21[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, -T20, -T21, +R] extends (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21) ⇒ R

    Returns an instance of Function21 memoized using the supplied mutable cache.

    Returns an instance of Function21 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21)
    calculating!
    res20: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21)
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21)
    res21: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21)
  32. class Memoize22[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, -T20, -T21, -T22, +R] extends (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22) ⇒ R

    Returns an instance of Function22 memoized using the supplied mutable cache.

    Returns an instance of Function22 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22)
    calculating!
    res21: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22)
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22)
    res22: String = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22)
  33. class Memoize3[-T1, -T2, -T3, +R] extends (T1, T2, T3) ⇒ R

    Returns an instance of Function3 memoized using the supplied mutable cache.

    Returns an instance of Function3 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3) =>
         |   println("calculating!")
         |   (x1, x2, x3).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3)
    calculating!
    res2: String = (1, 2, 3)
    
    scala> memoFn(1, 2, 3)
    res3: String = (1, 2, 3)
  34. class Memoize4[-T1, -T2, -T3, -T4, +R] extends (T1, T2, T3, T4) ⇒ R

    Returns an instance of Function4 memoized using the supplied mutable cache.

    Returns an instance of Function4 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4)
    calculating!
    res3: String = (1, 2, 3, 4)
    
    scala> memoFn(1, 2, 3, 4)
    res4: String = (1, 2, 3, 4)
  35. class Memoize5[-T1, -T2, -T3, -T4, -T5, +R] extends (T1, T2, T3, T4, T5) ⇒ R

    Returns an instance of Function5 memoized using the supplied mutable cache.

    Returns an instance of Function5 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5)
    calculating!
    res4: String = (1, 2, 3, 4, 5)
    
    scala> memoFn(1, 2, 3, 4, 5)
    res5: String = (1, 2, 3, 4, 5)
  36. class Memoize6[-T1, -T2, -T3, -T4, -T5, -T6, +R] extends (T1, T2, T3, T4, T5, T6) ⇒ R

    Returns an instance of Function6 memoized using the supplied mutable cache.

    Returns an instance of Function6 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6)
    calculating!
    res5: String = (1, 2, 3, 4, 5, 6)
    
    scala> memoFn(1, 2, 3, 4, 5, 6)
    res6: String = (1, 2, 3, 4, 5, 6)
  37. class Memoize7[-T1, -T2, -T3, -T4, -T5, -T6, -T7, +R] extends (T1, T2, T3, T4, T5, T6, T7) ⇒ R

    Returns an instance of Function7 memoized using the supplied mutable cache.

    Returns an instance of Function7 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6, x7) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6, x7).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7)
    calculating!
    res6: String = (1, 2, 3, 4, 5, 6, 7)
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7)
    res7: String = (1, 2, 3, 4, 5, 6, 7)
  38. class Memoize8[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, +R] extends (T1, T2, T3, T4, T5, T6, T7, T8) ⇒ R

    Returns an instance of Function8 memoized using the supplied mutable cache.

    Returns an instance of Function8 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6, x7, x8) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6, x7, x8).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8)
    calculating!
    res7: String = (1, 2, 3, 4, 5, 6, 7, 8)
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8)
    res8: String = (1, 2, 3, 4, 5, 6, 7, 8)
  39. class Memoize9[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, +R] extends (T1, T2, T3, T4, T5, T6, T7, T8, T9) ⇒ R

    Returns an instance of Function9 memoized using the supplied mutable cache.

    Returns an instance of Function9 memoized using the supplied mutable cache.

    scala> import com.twitter.storehaus.cache._
    
    scala> type Input = (Int, Int, Int, Int, Int, Int, Int, Int, Int)
    
    scala> val cache = MapCache.empty[Input, String].toMutable()
    cache: <munged>
    
    scala> val memoFn = Memoize(cache) { (x1, x2, x3, x4, x5, x6, x7, x8, x9) =>
         |   println("calculating!")
         |   (x1, x2, x3, x4, x5, x6, x7, x8, x9).toString
         | }
    memoFn: <munged>
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9)
    calculating!
    res8: String = (1, 2, 3, 4, 5, 6, 7, 8, 9)
    
    scala> memoFn(1, 2, 3, 4, 5, 6, 7, 8, 9)
    res9: String = (1, 2, 3, 4, 5, 6, 7, 8, 9)
  40. trait MutableCache[K, V] extends AnyRef

  41. trait MutableCacheProxy[K, V] extends MutableCache[K, V] with CacheProxied[MutableCache[K, V]]

    Proxy for Mergeables.

    Proxy for Mergeables. Methods not overrided in extensions will be forwared to Proxied self member

  42. class MutableFromImmutableCache[K, V] extends MutableCache[K, V]

    A Mutable cache generated by wrapping an immutable cache.

  43. class MutableLRUCache[K, V] extends JMapCache[K, V]

  44. class MutableMapCache[K, V] extends MutableCache[K, V]

    MutableCache backed by a scala mutable Map.

  45. class MutableTTLCache[K, V] extends MutableCache[K, V]

  46. case class RollOverFrequencyMS(toLong: Long) extends Product with Serializable

  47. sealed trait Side extends AnyRef

  48. case class SideACyclicIncrement[K](value: K) extends CyclicIncrement[K] with Product with Serializable

  49. case class SideBCyclicIncrement[K](value: K) extends CyclicIncrement[K] with Product with Serializable

  50. case class SideCCyclicIncrement[K](value: K) extends CyclicIncrement[K] with Product with Serializable

  51. class Stack[K] extends AnyRef

  52. class TTLCache[K, V] extends Cache[K, (Long, V)]

  53. case class WriteOperationUpdateFrequency(toInt: Int) extends Product with Serializable

Value Members

  1. object Atomic

  2. object Cache

    Companion object to Cache.

    Companion object to Cache. Contains a number of methods for generating various cache implementations.

  3. object CyclicIncrement

  4. object CyclicIncrementProvider

    This is an immutable implementation of a provider of cyclical increments.

    This is an immutable implementation of a provider of cyclical increments. The motivation is that we need ordered identifiers for caches, but we do not want to just increment an int as this has a theoretical upper limit (this is functional programming, our stuff doesn't crash, right?). This class allows the reuse of numbers, making it highly unlikely to run out of identifiers (it is still possible, but in a way that would be unavoidable -- if there is a key that stays in the stacks forever, thus never allowing us to reuse the increments after that key). This class ensures that when it is asked for a new increment, it will be greater than all currently outstanding increments at that time.

  5. object HeavyHittersPercent extends Serializable

  6. object JMapCache

  7. object LIRSCache

    This is an implementation of an immutable LIRS Cache based on the LIRS Cache impelementation in Clojure's core.cache: https://github.com/clojure/core.cache/blob/master/src/main/clojure/clojure/core/cache.clj.

    This is an implementation of an immutable LIRS Cache based on the LIRS Cache impelementation in Clojure's core.cache: https://github.com/clojure/core.cache/blob/master/src/main/clojure/clojure/core/cache.clj. The cache is described in this paper: http://citeseer.ist.psu.edu/viewdoc/download;jsessionid=EA23F554FDF98A258C6FDF0C8E98BFD1?doi=10.1.1.116.2184&rep=rep1&type=pdf

  8. object LIRSStacks

  9. object LRUCache

    "map" is the backing store used to hold key -> (index,value) pairs.

    "map" is the backing store used to hold key -> (index,value) pairs. The index tracks the access time for a particular key. "ord" is used to determine the Least-Recently-Used key in "map" by taking the minimum index.

  10. object MapCache

    Basic cache implementation using an immutable backing map.

  11. object Memoize

    Memoize supplies a number of functions for generating memoized versions of Scala's functions using a MutableCache instance.

    Memoize supplies a number of functions for generating memoized versions of Scala's functions using a MutableCache instance.

    For example,

    import com.twitter.storehaus.cache._
    
    scala> val sleepyToString = Memoize(MapCache.empty[Int, String].toMutable()) { i => println("CALCULATING!"); i.toString }
    sleepyToString: com.twitter.storehaus.cache.Memoize22[Int,String] = <function22>
    
    scala> sleepyToString(10)
    CALCULATING!
    res21: String = 10
    
    scala> sleepyToString(10)
    res22: String = 10
    
    // Get the backing function back out with backingFn:
    
    scala> sleepyToString.backingFn(10)
    CALCULATING!
    res23: String = 10
  12. object MutableCache

  13. object MutableLRUCache

    Creates a mutable LRU cache based on an insertion-order java.util.LinkedHashMap.

    Creates a mutable LRU cache based on an insertion-order java.util.LinkedHashMap. As per the com.twitter.storehaus.cache.MutableCache contract, gets will NOT modify the underlying map.

  14. object MutableMapCache

  15. object MutableTTLCache

  16. object RollOverFrequencyMS extends Serializable

  17. object SideA extends Side

  18. object SideB extends Side

  19. object SideC extends Side

  20. object Stack

  21. object TTLCache

    Immutable implementation of a *T*ime *T*o *L*ive cache.

    Immutable implementation of a *T*ime *T*o *L*ive cache.

    Every value placed into the cache via "put" must have an accompanying expiration time. Alternatively, placing a (K, V) pair into the TTLCache via putWithTime will generate an expiration time via the supplied clock function. After the supplied time-to-live Duration has passed, placing any new pair into the cache with "put" will evict all expired keys.

  22. object WriteOperationUpdateFrequency extends Serializable

Ungrouped