Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.twitter.finagle.memcached.java;
 
 
 
This is mainly for internal testing, not for external purpose
public class ClientTest {
  public static void main(String[] args) {
    Service<CommandResponseservice =
      ClientBuilder.safeBuild(
        ClientBuilder
          .get()
          .hosts("localhost:11211")
          .hostConnectionLimit(1)
          .codec(new Memcached()));
    Client client = Client.newInstance(service);
    testClient(client);
    // cache client with cluster
    CachePoolCluster cluster = CachePoolClusterUtil.newStaticCluster(
        ImmutableSet.of(new CacheNode("localhost", 11211, 1)));
    ClientBuilder builder = ClientBuilder.get().codec(new Memcached(null));
    com.twitter.finagle.memcached.Client memcachedClient = KetamaClientBuilder.get()
        .cachePoolCluster(cluster)
        .clientBuilder(builder)
        .build();
    client = new ClientBase(memcachedClient);
    testClient(client);
  }
  public static void testClient(Client client) {
    client.delete("foo").get();
    client.set("foo""bar").get();
    assert(client.get("foo").get().toString(Charset.defaultCharset()) == "bar");
    ResultWithCAS res = client.gets("foo").get();
    assert(client.cas("foo""baz"res.casUnique).get());
    assert(client.get("foo").get().toString(Charset.defaultCharset()) == "baz");
    client.delete("foo").get();
    ..println("passed.");
    client.release();
  }
New to GrepCode? Check out our FAQ X