-
Notifications
You must be signed in to change notification settings - Fork 86
Home
prasadwagle edited this page Feb 21, 2014
·
11 revisions
Storehaus is a library that makes it easy to work with asynchronous key value stores. Programming against Storehaus's interfaces instead of a specific API like Memcached or Redis gives your application tremendous flexibility. Want to sub in one backing store for another? No problem. The types and interface contract stay the same.
In testing, you can swap out your production store for a store backed by a function or a Map:
// All the same type:
val productionStore: ReadableStore[Long, String] = ???
val fnStore: ReadableStore[Long, String] = ReadableStore.fromFn(_.toString)
val mapStore: ReadableStore[Long, String] = ReadableStore.fromMap(Map[Long, String])
A great way to learn a new API is by running simple examples. Here are the minimal steps that will get you started in around 5 minutes. The commands and output are pretty self-explanatory.
git clone https://github.com/twitter/storehaus.git storehaus
cd storehaus
./sbt
[sbt start and update output deleted]
> compile
[compile output deleted]
> project storehaus-core
[info] Set current project to storehaus-core (in build file:/Users/pwagle/workspace/storehaus_expt/storehaus1/)
> console
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.9.3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_65).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import com.twitter.storehaus.ReadableStore
import com.twitter.storehaus.ReadableStore
scala> val store = ReadableStore.fromMap(Map[Int, String](1 -> "some value", 2 -> "other value"))
store: com.twitter.storehaus.ReadableStore[Int,String] = com.twitter.storehaus.MapStore@61a3fbde
scala> store.get(1).get
res0: Option[String] = Some(some value)
- Storehaus-Cache: The caches, and how to cache over ReadableStores.
- Function Memoization using the caches described above.
- Storehaus-Mysql