Memcache Java API / expiration time issue

Ryan Boyce ryan at ioffer.com
Wed Nov 10 21:31:47 PST 2004


Richard,

We're using Version 1.1.11 . We seem to have solved the issue. We were
trying to set the expiration time as a Unix timestamp. Thanks to Greg,
he sent us the internal commands to debug the issue and we found that we
should be setting the expiration time in seconds. Using this method it
seems to work fine. 

Thank You,
Ryan Boyce
Visit www.ioffer.com
An easier way to buy and sell
 

-----Original Message-----
From: memcached-bounces at lists.danga.com
[mailto:memcached-bounces at lists.danga.com] On Behalf Of Richard 'toast'
Russo
Sent: Wednesday, November 10, 2004 9:14 PM
To: Ryan Boyce
Cc: memcached at lists.danga.com
Subject: Re: Memcache Java API / expiration time issue

Ryan,

Which version of the Java API are you using?



On Tue, 9 Nov 2004, Ryan Boyce wrote:

> We're running memcached 1.1 server, and using Java memcached client
> API.  Suddenly after storing data variables onto server, we'd receive
an
> exception in retrieving variables back:
>
> #############################################
> com.danga.MemCached.MemCachedClient Tue Nov 09 01:04:20 PST 2004 -
++++
> ClassNot
> FoundException thrown while trying to deserialize for key: userObj
> com.danga.MemCached.MemCachedClient Tue Nov 09 01:04:20 PST 2004 -
++++
> exception thrown while trying to get object from cache for key:
userObj
> com.danga.MemCached.MemCachedClient Tue Nov 09 01:04:20 PST 2004 - +++
> failed while trying to deserialize for key: userObj
> java.io.IOException: +++ failed while trying to deserialize for key:
> userObj
>        at
> com.danga.MemCached.MemCachedClient.loadItems(MemCachedClient.java:10
> 84)
>        at
> com.danga.MemCached.MemCachedClient.get(MemCachedClient.java:850)
>        at
> com.danga.MemCached.MemCachedClient.get(MemCachedClient.java:816)
>        at _test__jsp._jspService(_test__jsp.java:61)
>
> com.danga.MemCached.SockIOPool Tue Nov 09 01:04:20 PST 2004 - ++++
> SockIOPool shutting down...
> com.danga.MemCached.SockIOPool Tue Nov 09 01:04:20 PST 2004 - ++++
> closing all internal pools.
> com.danga.MemCached.SockIOPool Tue Nov 09 01:04:20 PST 2004 - ++++
> SockIOPool finished shutting down.
> #########################################
>
> While standard Java objects like Integer can still be retrievied
> correctly, the expiration set and replace commands do not work
> correctly:
> a call to memClient.set(key, var, expireTime) would immediately expire
> the variable.  I found that out by immediately calling get on that
> variable:
>
> MemCachedClient mc = new MemCachedClient();
>
> String numberKey = "numberKey";
> Integer num = (Integer)mc.get(numberKey);
> if ( num == null )
> {
>    num = new Integer(49);
>    out.println("Cached number "+ num +" is NOT found "+ (new
> java.util.Date()) );
>    Calendar later = Calendar.getInstance();
>    later.add(Calendar.MINUTE, 5);
>    java.util.Date laterTime = later.getTime();
>    out.println("Storing number "+ num +" : "+ mc.set(numberKey, num)
);
>    //out.println("  expiring at "+ laterTime );
>
>    num = (Integer)mc.get(numberKey);
>    out.println("search number back again: "+ num );
> }
> else
> {
>    out.println("Cached number "+ num +" is found "+ (new
> java.util.Date()) );
>    Calendar later = Calendar.getInstance();
>    later.add(Calendar.HOUR, 1);
>    java.util.Date laterTime = later.getTime();
>    //out.println("set number "+ num +" : "+ mc.set(numberKey, num,
> laterTime) +" expiring at "+ laterTime );
>
>    num = new Integer( num.intValue() + 1 );
>    out.println("replace number "+ num +" : "+ mc.replace(numberKey,
> num, laterTime ) +" to new value "+ num.intValue() +" expiring "+
> laterTime);
>
>    num = (Integer)mc.get(numberKey);
>    out.println("search number back again: "+ num );
> }
>
> #### Codes
> ####################################################
> #### Output
>
> ( 1st call )
> Cached number 49 is NOT found Tue Nov 09 01:11:02 PST 2004 Storing
> number 49 : true search number back again: 49
>
> ( 2nd call )
> Cached number 49 is found Tue Nov 09 01:10:48 PST 2004
> set number 49 : true expiring at Tue Nov 09 01:11:48 PST 2004 search
> number back again: null
>
>
>
> Thank You,
> Ryan Boyce
> Visit www.ioffer.com
> An easier way to buy and sell
>
>
>



More information about the memcached mailing list