Code example for MapMaker

0
 
    protected Map<MemoryPipeKey, DbBatch> cache;
 
    public void afterPropertiesSet() throws Exception {
        // 一定要设置过期时间,因为针对rollback操作,不会有后续的节点来获取数据,需要自动过期删除掉 
        cache = new MapMaker().expireAfterWrite(timeout, TimeUnit.MILLISECONDS).softValues().makeMap();
    } 
 
    // ============== setter / getter =============== 
 
    public void setTimeout(Long timeout) {
        this.timeout = timeout;
    } 
 
}