Storehaus是一个能够让异步键值存储更加方便的开发工具。Storehaus是基于Twitter'sFuture所建立的。
Storehaus的核心模块定义了三个特征:只读ReadableStore,只写WritableStore和只写Store.这三个特征都非常的小:
package com.twitter.storehausimport com.twitter.util.{ Closable, Future, Time }trait ReadableStore[-K, +V] extends Closeable { def get(k: K): Future[Option[V]] def multiGet[K1 <: K](ks: Set[K1]): Map[K1, Future[Option[V]]] override def close(time: Time) = Future.Unit}trait WritableStore[-K, -V] { def put(kv: (K, V)): Future[Unit] = multiPut(Map(kv)).apply(kv._1) def multiPut[K1 <: K](kvs: Map[K1, V]): Map[K1, Future[Unit]] = kvs.map { kv => (kv._1, put(kv)) } override def close(time: Time) = Future.Unit}trait Store[-K, V] extends ReadableStore[K, V] with WritableStore[K, Option[V]
评论