Here's rest of the code:

public class Memcache {
    private static int EXPIRY = 60*60*24*30;
    private static final String POSTIDKEY="POSTID_";
    
    private static boolean has(String key) {
        return MemcacheServiceFactory.getMemcacheService().contains(key) && 
get(key).length()>0;
    }
    
    private static String get(String key) {
        try {
            return (String) 
MemcacheServiceFactory.getMemcacheService().get(key);
        } catch (Exception e) { return "";    }
    }
    
    private static void put(String key, String value, int expiry) {
        MemcacheServiceFactory.getMemcacheService().put(key, value, 
Expiration.byDeltaSeconds(expiry));
    }
    
    private static void delete(String key) {
        MemcacheServiceFactory.getMemcacheService().delete(key);
    }
    
    public static boolean hasById(Long id) { return has(POSTIDKEY+id); }
    public static String getById(Long id) { return get(POSTIDKEY+id); }
    public static void putById(Long id, String value) { put(POSTIDKEY+id, 
value, EXPIRY); }
    public static void flushById(Long id) { delete(POSTIDKEY+id); }

}


    public static String byid(HttpServletRequest req) {
        Long id=0L;
        try { id=Long.parseLong(req.getParameter("id")); } catch (Exception 
e) {}
        if (id==0) return "";
        if (Memcache.hasById(id)) return Memcache.getById(id);
        String res = V1Post.getById(id);
        Memcache.putById(id, res);
        return res;
    }


Does anyone know where the error is in my code? And why Memcache.hasById(id) 
seems to always return false?

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine-java/-/YvgEPKy04JIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to