Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

shutdown memcache client in sample

  • Loading branch information...
commit 5b81a59fbe115a00a00fec7357a8cb5885865874 1 parent a5b140a
@ryanbrainard ryanbrainard authored
View
13 src/main/java/com/heroku/devcenter/Main.java
@@ -1,10 +1,5 @@
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;
@@ -12,6 +7,11 @@
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();
}
}
View
16 src/main/java/com/heroku/devcenter/spring/Main.java
@@ -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();
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.