in storehaus-memcache/src/main/scala/com/twitter/storehaus/memcache/MergeableMemcacheStore.scala [44:71]
def apply[K, V](
client: Client,
ttl: Duration = MemcacheStore.DEFAULT_TTL,
flag: Int = MemcacheStore.DEFAULT_FLAG,
maxRetries: Int = MAX_RETRIES)
(kfn: K => String)(
implicit inj: Injection[V, ChannelBuffer], semigroup: Semigroup[V]
): MergeableMemcacheStore[K, V] =
new MergeableMemcacheStore[K, V](
MemcacheStore(client, ttl, flag), maxRetries)(kfn)(inj, semigroup)
}
/** Returned when merge fails after a certain number of retries */
class MergeFailedException(val key: String)
extends RuntimeException("Merge failed for key " + key)
/**
* Mergeable MemcacheStore that uses CAS.
*
* The store supports multiple concurrent writes to the same key, but you might
* see a performance hit if there are too many concurrent writes to a hot key.
* The solution is to group by a hot key, and use only a single (or few) writers to that key.
*/
class MergeableMemcacheStore[K, V](underlying: MemcacheStore, maxRetries: Int)(kfn: K => String)
(implicit inj: Injection[V, ChannelBuffer],
override val semigroup: Semigroup[V])
extends ConvertedStore[String, K, ChannelBuffer, V](underlying)(kfn)(inj)
with MergeableStore[K, V] {