Code example for Cache

Methods: getIfPresentput

        //Too early 
        if (cal.getTime().after(new Date()))
        //Are we already working on this url? 
        if (workCache.getIfPresent(url) != null)
        //Scrape it!"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);
    public void ack(Object id) 
        String url = (String) id;
        Date startTime = workCache.getIfPresent(url);
Stop searching for code, let great code find you!  Add Codota to your java IDE