Package

com.twitter

storehaus

Permalink

package storehaus

Visibility
  1. Public
  2. All

Type Members

  1. abstract class AbstractReadableStore[-K, +V] extends ReadableStore[K, V]

    Permalink

    Abstract extension of the defined trait to minimize trait bloat.

    Abstract extension of the defined trait to minimize trait bloat. Probably mostly useful from Java or in anonymous instances whose return types are constrained to be ReadableStore. Try not to expose AbstractReadableStore in your APIs.

  2. class BatchedReadableStore[K, V] extends ReadableStoreProxy[K, V]

    Permalink

    Ever wished you could do a multiGet for 10,000 keys, but spread out over several multiGets? Use the BatchedReadableStore.

  3. class BatchedStore[K, V] extends BatchedReadableStore[K, V] with Store[K, V]

    Permalink

    Adds batched writes to BatchedReadableStore

  4. class CacheStore[K, V] extends Store[K, V]

    Permalink

    Generates a com.twitter.storehaus.Store backed by a com.twitter.storehaus.cache.MutableCache.

  5. class CachedReadableStore[K, V] extends ReadableStore[K, V]

    Permalink
  6. class ComposedStore[-K, V, V2, V3 >: V] extends AbstractReadableStore[K, V2]

    Permalink

    A store that is made from looking up values in the first store, then using that as the key in the second.

    A store that is made from looking up values in the first store, then using that as the key in the second. When used with com.twitter.storehaus.ConvertedStore you can do some powerful sequential processing of stores

  7. class ConcurrentHashMapStore[K, V] extends JMapStore[K, V]

    Permalink

    A simple JMapStore whose underlying store is a Java ConcurrentHashMap useful if you are going to be modifying a store from many threads, something you in general cannot do unless the docs specifically say that a store is safe for that.

  8. sealed trait ConsistencyLevel extends AnyRef

    Permalink

    N - total replicas One - 1 successful operation is sufficient to consider the operation as complete Quorum - N/2 + 1 successful operations are sufficient to consider the operation as complete All - N successful operations are required

  9. class ConvertedReadableStore[K1, -K2, V1, +V2] extends AbstractReadableStore[K2, V2]

    Permalink

    Convert the keys/values of a store.

    Convert the keys/values of a store.

    Value conversion returns a Future because V1 => V2 may fail, and we are going to convert to a future anyway (so, a Try is kind of a Future that is not async). Thus we might as well add the flexibility of accepting a V1 => Future[V2], though in practice Future.value/exception will generally be used.

  10. class ConvertedStore[K1, -K2, V1, V2] extends ConvertedReadableStore[K1, K2, V1, V2] with Store[K2, V2]

    Permalink

    Use an injection on V2,V1 to convert a store of values V2.

    Use an injection on V2,V1 to convert a store of values V2. If the value stored in the underlying store cannot be converted back to V2, then you will get a Future.exception containing the string "cannot be converted" TODO: we should add a specific exception type here so we can safely filter these cases to Future.None if we so choose.

  11. class EagerWriteThroughCacheStore[K, V] extends Store[K, V]

    Permalink
  12. class EnrichedQueryableStore[-K, V, Q] extends EnrichedStore[K, V]

    Permalink

    Since

    1/22/14

  13. class EnrichedReadableStore[-K, +V] extends AnyRef

    Permalink

    Enrichment on the com.twitter.storehaus.ReadableStore trait.

    Enrichment on the com.twitter.storehaus.ReadableStore trait. Storehaus uses the enrichment pattern instead of adding these methods directly to the trait because many of the functions (mapValues, for example) have different meanings for ReadableStore, Store and MergeableStore.

    import ReadableStore.enrich

    to get access to these methods.

    TODO: in scala 2.10 this should be a value class

  14. class EnrichedStore[-K, V] extends AnyRef

    Permalink

    Enrichment on the Store[K, V] trait.

    Enrichment on the Store[K, V] trait. Storehaus uses the enrichment pattern instead of adding these methods directly to the trait because many of the functions (mapValues, for example) have different meanings for ReadableStore, Store and MergeableStore.

    import Store.enrich

    to get access to these methods.

    TODO: in scala 2.10 this should be a value class

  15. trait FutureCollector extends Serializable

    Permalink

    A type to represent how Seq of futures are collected into a future of Seq[T]

  16. class IndexedSeqReadableStore[+V] extends ReadableStore[Int, V]

    Permalink

    Simple wrapper on IndexedSeq[V] to make it accessible as a ReadableStore

  17. trait IterableStore[+K, +V] extends AnyRef

    Permalink

    Trait for stores that allow iterating over their key-value pairs.

  18. class JMapStore[K, V] extends Store[K, V]

    Permalink

    A Store instance which is backed by a Java Map (by default JHashMap) Obviously, there is no optimization of the multiGet/multiPut methods on this store and these are just implemented using the default implementation from Store.

  19. class MapStore[K, +V] extends ReadableStore[K, V] with IterableStore[K, V]

    Permalink

    MapStore is a ReadableStore backed by a scala immutable Map.

  20. class MinBatchingReadableStore[K, V] extends ReadableStoreProxy[K, V]

    Permalink

    Instead of doing a get, this combinator always does a multiGet after enough gets have been created.

  21. class MissingShardException[K] extends RuntimeException

    Permalink

    This is only thrown when a shard is expected but somehow absent.

    This is only thrown when a shard is expected but somehow absent. For instance, in the combinators, we expect all the underlying gets to behave correctly this exception put into a Future when a user tries to put to an invalid shard

  22. class MissingValueException[K] extends RuntimeException

    Permalink

    This is only thrown when a value is expected but somehow absent.

    This is only thrown when a value is expected but somehow absent. For instance, in the combinators, we expect all the underlying gets to behave correctly this exception is used when a dependent store is not returning correct data.

  23. class PivotedReadableStore[K, -OuterK, InnerK, +V] extends ReadableStore[OuterK, ReadableStore[InnerK, V]]

    Permalink
  24. trait Proxied[T] extends AnyRef

    Permalink

    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
  25. trait QueryableStore[Q, +V] extends AnyRef

    Permalink

    Since

    1/14/14

  26. class ReadFailedException[K] extends RuntimeException

    Permalink

    Thrown when a read operation fails due to unsatisfied consistency level

  27. class ReadThroughStore[K, V] extends ReadableStore[K, V]

    Permalink

    Provides read-through caching on a readable store fronted by a cache.

    Provides read-through caching on a readable store fronted by a cache.

    Keys are fetched from backing store on cache miss and cache read failures.

    All cache operations are best effort i.e. 'get' will return the key from backing store even if adding/updating the cached copy fails.

    On the other hand, any failure while reading from backing store is propagated to the client.

  28. trait ReadableStore[-K, +V] extends Closable

    Permalink

    Main trait to represent asynchronous readable stores Here you see the tri-state logic:

    Main trait to represent asynchronous readable stores Here you see the tri-state logic:

    • Future(Some(v)) - The store has the item
    • Future(None) - The store definitely DOES NOT have the item (not the same as no answer).
    • Future.exception - Some kind of unexpected failure (including non-answer).
  29. trait ReadableStoreProxy[K, V] extends ReadableStore[K, V] with Proxied[ReadableStore[K, V]]

    Permalink

    A proxy for ReadableStores.

    A proxy for ReadableStores. Methods not overridden in extensions will be forwarded to Proxied self member

  30. class ReplicatedReadableStore[-K, +V] extends AbstractReadableStore[K, V]

    Permalink

    Replicates reads to a seq of stores and returns the first successful value (empty or not)

  31. class ReplicatedStore[-K, V] extends ReplicatedReadableStore[K, V] with Store[K, V]

    Permalink

    Replicates writes to all stores, and takes the first successful read.

  32. class RetriesExhaustedException[K] extends RuntimeException

    Permalink

    This is thrown when a retryable store runs out of retries when looking for a key.

  33. class RetryingReadableStore[-K, +V] extends ReadableStore[K, V]

    Permalink

    Use the ReadableStore abstraction when each read from the backend store involves a time-taking task.

    Use the ReadableStore abstraction when each read from the backend store involves a time-taking task. A stream of backoffs are passed in so that we only wait for a finite time period for the task to complete.

  34. class RetryingStore[-K, V] extends RetryingReadableStore[K, V] with Store[K, V]

    Permalink

    Delegate put to the underlying store and allow retriable semantics for get.

  35. class SearchingReadableStore[-K, +V] extends ReadableStore[K, V]

    Permalink

    Returns a ReadableStore that attempts reads out of the supplied Seq[ReadableStore] in order and returns the first non-exceptional value that satisfies the supplied predicate.

    Returns a ReadableStore that attempts reads out of the supplied Seq[ReadableStore] in order and returns the first non-exceptional value that satisfies the supplied predicate.

    multiGet attempts a full multiGet of the first store, then follows up on missing or failed keys with individual gets to the underlying stores (as failures for each key can happen at different times).

  36. class ShardedReadableStore[-K1, -K2, +V, +S <: ReadableStore[K2, V]] extends ReadableStore[(K1, K2), V]

    Permalink

    combines a mapping of ReadableStores into one ReadableStore that internally routes Note: if K1 is absent from the routes, you will always get Future.None as a result.

    combines a mapping of ReadableStores into one ReadableStore that internally routes Note: if K1 is absent from the routes, you will always get Future.None as a result. you may want to combine this with ReadableStore.composeKeyMapping the change (K => (K1,K2))

  37. class ShardedStore[-K1, -K2, V, +S <: Store[K2, V]] extends ShardedReadableStore[K1, K2, V, S] with Store[(K1, K2), V]

    Permalink

    combines a mapping of Stores into one Store that internally routes Note: if a K1 is absent from the routes, any put will give a

    combines a mapping of Stores into one Store that internally routes Note: if a K1 is absent from the routes, any put will give a

    Future.exception(new MissingShardException(k1))
  38. trait Store[-K, V] extends ReadableStore[K, V] with WritableStore[K, Option[V]]

    Permalink

    Main trait for stores can be both read from and written to

  39. trait StoreProxy[K, V] extends Store[K, V] with Proxied[Store[K, V]]

    Permalink

    A Proxy for Stores.

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

  40. class TunableReplicatedReadableStore[-K, +V] extends AbstractReadableStore[K, V]

    Permalink

    Replicates reads to a seq of stores and returns the value based on picked read consistency.

    Replicates reads to a seq of stores and returns the value based on picked read consistency.

    Consistency semantics: One - returns after first successful read, fails if all underlying reads fail Quorum - returns after at least N/2 + 1 reads succeed and return the same value, fails otherwise All - returns if all N reads succeed and return the same value, fails otherwise

  41. class TunableReplicatedStore[-K, V] extends TunableReplicatedReadableStore[K, V] with Store[K, V]

    Permalink

    Replicates writes to a seq of stores, and returns after picked write consistency is satisfied.

    Replicates writes to a seq of stores, and returns after picked write consistency is satisfied.

    Consistency semantics: One - returns after first successful write (other writes can complete in the background), fails if no write is successful Quorum - returns after N/2 + 1 writes succeed (other writes can complete in the background), fails otherwise All - returns if all N writes succeed, fails otherwise

    Additionally, the following operations are supported: readRepair - read repair any missing or incorrect data (only for Quorum reads) writeRollback - delete the key on all replicas if write fails (only for Quorum writes and All writes)

  42. class UnpivotedReadableStore[-K, OuterK, InnerK, +V] extends ReadableStore[K, V]

    Permalink

    ReadableStore enrichment which presents a ReadableStore[K, V] over top of a packed ReadableStore[OuterK, Map[InnerK, V]].

  43. class UnpivotedStore[-K, OuterK, InnerK, V] extends UnpivotedReadableStore[K, OuterK, InnerK, V] with Store[K, V]

    Permalink

    Store enrichment which presents a Store[K, V] over top of a packed Store[OuterK, Map[InnerK, V]].

  44. trait WithPutTtl[K, V, S <: WritableStore[K, Option[V]]] extends AnyRef

    Permalink

    Trait for building mutable store with TTL.

  45. trait WritableStore[-K, -V] extends Closable

    Permalink

    Main trait for mutable stores.

    Main trait for mutable stores. Instances may implement EITHER put, multiPut or both. The default implementations are in terms of each other.

  46. trait WritableStoreProxy[K, V] extends WritableStore[K, V] with Proxied[WritableStore[K, V]]

    Permalink

    A Proxy for WritableStores.

    A Proxy for WritableStores. Methods not overriden in extensions will be forwarded to Proxied self member

  47. class WriteFailedException[K] extends RuntimeException

    Permalink

    Thrown when a write operation fails due to unsatisfied consistency level

  48. class WriteThroughStore[K, V] extends ReadThroughStore[K, V] with Store[K, V]

    Permalink

    Provides write-through caching on a store fronted by a cache.

    Provides write-through caching on a store fronted by a cache.

    All cache operations are best effort. i.e. a write will succeed if the key was written to backing store even when adding/updating the cached copy of the key fails.

    On the other hand, any failure while writing to backing store is propagated to the client.

    If invalidate flag is set, any keys that fail to write to backing store are attempted to be removed from cache, rather than having the old value still in cache.

Value Members

  1. object CollectionOps

    Permalink

    Helpful transformations on maps and collections.

    Helpful transformations on maps and collections. These are combinators or transformers on collections that should probably be somewhere in the scala collection API, but are not.

  2. object ConsistencyLevel

    Permalink
  3. object EmptyReadableStore extends AbstractReadableStore[Any, Nothing]

    Permalink

    Concrete empty store implementation.

  4. object FutureCollector extends Serializable

    Permalink

    Some factory methods and instances of FutureCollector that are used in storehaus

  5. object FutureOps

    Permalink

    Some combinators on Futures or Seqs of Futures that are used internally These should arguably exist in util-core.

  6. object IterableStore

    Permalink
  7. object PivotOps

    Permalink

    Methods used in the various unpivot stores.

  8. object PivotedReadableStore

    Permalink

    ReadableStore enrichment for ReadableStore[OuterK, ReadableStore[InnerK, V]] on top of a ReadableStore[K, V]

  9. object QueryableStore

    Permalink
  10. object ReadableStore

    Permalink

    Holds various factory and transformation functions for ReadableStore instances

  11. object ShardedReadableStore

    Permalink

    Factory methods to create ShardedReadableStore instances

  12. object ShardedStore

    Permalink

    Factory methods to create ShardedStore instances

  13. object Store

    Permalink

    Factory methods and some combinators on Stores

  14. object TunableReplicatedStore

    Permalink

    Factory method to create TunableReplicatedStore instances

Ungrouped