How to save object into memcache

43 views
Skip to first unread message

Pratik Patel

unread,
Mar 29, 2013, 8:44:17 AM3/29/13
to spymem...@googlegroups.com



Hi,

I am new to memcache and trying to save an object in the memcache server.

Unfortunately, the object is not saved properly and while trying to retrieve, I am getting only null value.

I tried to write the Transcoder but no luck.

Here is the code snippet.

          MemcachedClient memClient = new MemcachedClient(new BinaryConnectionFactory(),AddrUtil.getAddresses("192.168.6.214:11211"));         
          Transcoder<Employee> transcoder = new EmployeeTranscoder();
          Employee e=new Employee(1,"Test User",1500);
          System.out.println("Putting the employee into memcache");
          memClient.set(keyName, 36000, e, transcoder);
          Employee obj = memClient.get(keyName,transcoder);
          System.out.println("Fetching the object from memcache: "+obj);

Attached is the EmployeeTranscoder.java file.

The value string in the DB is, ACED0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Only first four bytes are populated, rest are null. I have attached screenshot of wireshark capture for set operation.

Can someone please advise how to fix the problem?


Many Thanks,
Pratik


screenshot-set-operation.jpg
EmployeeTranscoder.java
Reply all
Reply to author
Forward
0 new messages