async, non-blocking memcached client using akka
Scala
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
project
src
.gitignore
LICENSE
README.md
build.sbt

README.md

akka-memcached

async, non-blocking memcached client using akka

inspired by, but much simpler than, this project: https://github.com/derekjw/fyrie-redis

info on akka io / iteratee library: http://doc.akka.io/docs/akka/2.0.3/scala/io.html

Disclaimer

This client is has not seen extensive production testing and should be used with care.

Maintainers

Features

  • Supports set, get, and delete memcached instructions
  • All instructions are non-blocking.
  • The set and delete methods are fire-and-forget, the get method returns an akka.dispatch.Future
  • Uses consistent hashing to distribute data across multiple memcached servers
  • Deduplicates keys: If multiple clients make a request for the same key, only a single get request will be made for that key, and results will be forwarded to each requesting client
  • Will reconnect to memcached if the connection is lost, and will complete any pending futures if the connection is re-established

How to build

Usage

  • Include this jar in your project
  • Create a new instance of RealMemcachedClient
  • It is necessary to have an implicit serializer when calling the get or set client methods

Example

import akka.util.duration._
import akka.util.Timeout
import akka.dispatch.Await
import com.klout.akkamemcached.RealMemcachedClient
import com.klout.akkamemcached.Serialization.JBoss

object Test {
	// Create a client that connects to localhost on a single connection
    val client = new RealMemcachedClient(List(("localhost", 11211)), 1)

    // Store a value
    client.set("key", "value", 1 hour)

    // Retrieve a value
    val valueFuture = client.get("key")
    val result = Await.result(valueFuture, 5 seconds)

    // Delete a value
    client.delete("key")
}