Permalink
Browse files

shutdown memcache client in sample

  • Loading branch information...
1 parent a5b140a commit 5b81a59fbe115a00a00fec7357a8cb5885865874 @ryanbrainard ryanbrainard committed Feb 7, 2012
Showing with 11 additions and 18 deletions.
  1. +7 −6 src/main/java/com/heroku/devcenter/Main.java
  2. +4 −12 src/main/java/com/heroku/devcenter/spring/Main.java
@@ -1,17 +1,17 @@
package com.heroku.devcenter;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.URISyntaxException;
-import java.util.Collections;
-
import net.spy.memcached.ConnectionFactory;
import net.spy.memcached.ConnectionFactoryBuilder;
import net.spy.memcached.ConnectionFactoryBuilder.Protocol;
import net.spy.memcached.MemcachedClient;
import net.spy.memcached.auth.AuthDescriptor;
import net.spy.memcached.auth.PlainCallbackHandler;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.URISyntaxException;
+import java.util.Collections;
+
public class Main {
/**
@@ -24,10 +24,11 @@ public static void main(String[] args) throws IOException, URISyntaxException {
new PlainCallbackHandler(System.getenv("MEMCACHE_USERNAME"), System.getenv("MEMCACHE_PASSWORD")));
ConnectionFactoryBuilder factoryBuilder = new ConnectionFactoryBuilder();
ConnectionFactory cf = factoryBuilder.setProtocol(Protocol.BINARY).setAuthDescriptor(ad).build();
-
+
MemcachedClient memcachedClient = new MemcachedClient(cf, Collections.singletonList(new InetSocketAddress(System.getenv("MEMCACHE_SERVERS"), 11211)));
memcachedClient.add("test", 0, "testData");
System.out.println(memcachedClient.get("test"));
+ memcachedClient.shutdown();
}
}
@@ -1,20 +1,11 @@
package com.heroku.devcenter.spring;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.URISyntaxException;
-import java.util.Collections;
-
-import net.spy.memcached.ConnectionFactory;
-import net.spy.memcached.ConnectionFactoryBuilder;
-import net.spy.memcached.ConnectionFactoryBuilder.Protocol;
import net.spy.memcached.MemcachedClient;
-import net.spy.memcached.auth.AuthDescriptor;
-import net.spy.memcached.auth.PlainCallbackHandler;
-
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-import org.springframework.context.support.GenericXmlApplicationContext;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
public class Main {
@@ -30,6 +21,7 @@ public static void main(String[] args) throws IOException, URISyntaxException {
memcachedClient.add("testSpring", 0, "testDataSpring");
System.out.println(memcachedClient.get("testSpring"));
+ memcachedClient.shutdown();
}
}

0 comments on commit 5b81a59

Please sign in to comment.