Skip to content

Commit

Permalink
add basic get
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgolick committed Nov 16, 2009
1 parent c9eb283 commit 9ce0a36
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/main/scala/Smemcache.scala
@@ -1,7 +1,8 @@
package com.protose.smemcache
import java.net.InetSocketAddress
import net.spy.memcached.MemcachedClient

object Smemcache {
object Memcache {
implicit def string2InetSocketAddress(string: String):
InetSocketAddress = {
val split = string.split(":")
Expand All @@ -11,7 +12,11 @@ object Smemcache {
}
}
}
class Smemcache {

class Memcache(val client: MemcachedClient) {
def get(key: String): Any = {
client.get(key)
}
}

// vim: set ts=4 sw=4 et:
13 changes: 12 additions & 1 deletion src/test/scala/SmemcacheSpec.scala
Expand Up @@ -3,7 +3,8 @@ import org.specs._
import org.specs.mock.Mockito
import org.mockito._
import java.net.InetSocketAddress
import com.protose.smemcache.Smemcache._
import com.protose.smemcache.Memcache._
import net.spy.memcached.MemcachedClient

object SmemcacheSpec extends Specification with Mockito {
"implicitly converting a string to InetSocketAddress" should {
Expand All @@ -19,6 +20,16 @@ object SmemcacheSpec extends Specification with Mockito {
addr.getPort must_== 11211
}
}

"doing a cache get" should {
"delegate to the underlying client" in {
val underlyingClient = mock[MemcachedClient]
underlyingClient.get("someKey") returns "some value"
val cache = new Memcache(underlyingClient)
cache.get("someKey") must_== "some value"
underlyingClient.get("someKey") was called
}
}
}

// vim: set ts=4 sw=4 et:

0 comments on commit 9ce0a36

Please sign in to comment.