Code example for Cache

Methods: getIfPresentinvalidate

0
 
    @Override 
    public void ack(Object id) 
    { 
        String url = (String) id;
        Date startTime = workCache.getIfPresent(url);
 
        if (startTime == null) { 
            logger.warn("Scraping took > 10min!: {}", url);
            return; 
        } 
 
        //update the cache 
        logger.info("Scraping complete for: {}", url);
        PreparedStatement ps = session.prepare("UPDATE scrape_list SET last_update = ? where url = ?");
 
        BoundStatement bs = ps.bind(startTime, url);
        session.execute(bs);
 
 
        workCache.invalidate(url);
    } 
 
    @Override 
    public void fail(Object id) 
    {