Immutable Cache trait for use with Storehaus stores.
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
A clock is anything which provides a succession of values.
MutableCache that applies a filter to each value.
Returns a MutableCache instance backed by the supplied java.util.Map.
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
Proxy for Mergeables.
Proxy for Mergeables. Methods not overrided in extensions will be forwared to Proxied self member
A Mutable cache generated by wrapping an immutable cache.
MutableCache backed by a scala mutable Map.
Companion object to Cache.
Companion object to Cache. Contains a number of methods for generating various cache implementations.
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.
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
"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.
Basic cache implementation using an immutable backing map.
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
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.
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.
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