Skip to content

Commit

Permalink
Merge pull request #37 from mspielberg/master
Browse files Browse the repository at this point in the history
Enable configuration of hash algorithm
  • Loading branch information
lloydmeta committed May 4, 2016
2 parents 46ef64c + b35bf7a commit 0a877ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/scala/shade/memcached/Configuration.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package shade.memcached

import net.spy.memcached.ops.OperationQueueFactory
import net.spy.memcached.{ DefaultConnectionFactory, HashAlgorithm }

import scala.concurrent.duration._

Expand Down Expand Up @@ -38,6 +39,8 @@ import scala.concurrent.duration._
* @param writeQueueFactory can be used to customize the write queue,
* i.e. the queue of operations waiting to be sent to Memcached by SpyMemcached.
* If `None`, the default SpyMemcached implementation (an unbounded LinkedBlockingQueue) is used.
*
* @param hashAlgorithm the method for hashing a cache key for server selection
*/
case class Configuration(
addresses: String,
Expand All @@ -49,7 +52,8 @@ case class Configuration(
shouldOptimize: Boolean = false,
opQueueFactory: Option[OperationQueueFactory] = None,
writeQueueFactory: Option[OperationQueueFactory] = None,
readQueueFactory: Option[OperationQueueFactory] = None)
readQueueFactory: Option[OperationQueueFactory] = None,
hashAlgorithm: HashAlgorithm = DefaultConnectionFactory.DEFAULT_HASH)

object Protocol extends Enumeration {
type Type = Value
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/shade/memcached/MemcachedImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ class MemcachedImpl(config: Configuration, ec: ExecutionContext) extends Memcach
.setReadOpQueueFactory(config.readQueueFactory.orNull)
.setWriteOpQueueFactory(config.writeQueueFactory.orNull)
.setShouldOptimize(config.shouldOptimize)
.setHashAlg(config.hashAlgorithm)

val withTimeout = config.operationTimeout match {
case duration: FiniteDuration =>
Expand Down

0 comments on commit 0a877ec

Please sign in to comment.