Code example for Cache

Methods: getIfPresentput

0
        //Too early 
        if (cal.getTime().after(new Date()))
            return; 
 
        //Are we already working on this url? 
        if (workCache.getIfPresent(url) != null)
            return; 
 
        //Scrape it! 
        logger.info("Emitting url: {} for {} levels deep", url, depth);
        Date now = new Date(); 
        workCache.put(url, now); //mark the start time
        collector.emit(new Values(url,url,now,depth), url);
    } 
 
    @Override 
    public void ack(Object id) 
    { 
        String url = (String) id;
        Date startTime = workCache.getIfPresent(url);
Experience pair programming with AI  Get Codota for Java