CN-GuoZiyang / MYDB

一个简单的数据库实现
GNU General Public License v3.0
860 stars 218 forks source link

缓存的close()方法好像有bug #5

Open YeYuan1107 opened 2 years ago

YeYuan1107 commented 2 years ago
protected void close() {
        lock.lock();
        try {
            Set<Long> keys = cache.keySet();
            for (long key : keys) {
                release(key);
                references.remove(key);
                cache.remove(key);
            }
        } finally {
            lock.unlock();
        }
}

release()方法在key的引用降到0时才会进行回源,如果key的ref没有到0不就没有回源吗,并没有在关闭的时候把缓存中所有资源回源