2 Minutes To Code (β Version)

Spy-memcached, java client for memcached - 2 minute tutorial

How to connect to memcache server

This example shows how to establish a connection to a running memcached server running on localhost (hostname of the local system) on port 11211 (default port of memcached server).

You create an object of class net.spy.memcached.MemcachedClient by passing its construcor an object of class java.net.InetSocketAddress pointing to localhost and port 11211.

The next few pages explain ,how to use this connection to get and put objects in the memcached server.
package com.techfundaes.memcacheBag;

import java.net.InetSocketAddress;

import net.spy.memcached.MemcachedClient;

public class CreateMemcacheClient
	public static void main(String[] args) throws Exception
		MemcachedClient memcacheClient = new MemcachedClient(new InetSocketAddress("localhost", 11211));