Java client - Storing custom objects

Jure Petrovic fonz at siol.net
Fri Dec 8 09:35:02 UTC 2006


Hello, 


how would you store a custom object in memcached using java client?
Let's say we have a class like this:

public class Adress {
	String street;
	int streetNum;
	int zipCode;
	String city;
}
	
I also implemented a getObject() method...

public static Object getObject(String street, int streetNum, int
zipCode, String city) {
		Adress ret = new Adress(street,streetNum,zipCode,city);
		return ret;
	}


In my program now I do:

Object a = Adress.getObject("Some street",10,1111,"Some City");
.....
Boolean bl = mc.set("adress", a);


bl always evaluates to "false", and when I do mc.get() I always get an
exception, saying that an object is null.

Maybe someone knows how to store(serialize) object like that?



I would really appreciate your help.
Thank you in advance, 

Jure Petrovic












More information about the memcached mailing list