jankotek / mapdb

MapDB provides concurrent Maps, Sets and Queues backed by disk storage or off-heap-memory. It is a fast and easy to use embedded Java database engine.
https://mapdb.org
Apache License 2.0
4.89k stars 873 forks source link

Data in FileDB will not expired, so that the usage of disk space can't be limited #975

Open Authorlove opened 4 years ago

chenqi0805 commented 3 years ago

I have a similar issue. Even for memory DB expire does not work for 3.0.8:

@Test
    public void testExpiration() throws InterruptedException {
        HTreeMap<String, String> map = (HTreeMap<String, String>) DBMaker
//                .fileDB("map").fileDeleteAfterClose()
                .memoryDB()
                .make().hashMap("map")
                .expireAfterCreate(10)
                .createOrOpen();
        map.put("a", "b");
        Thread.sleep(4000);
        assertNull(map.get("a"));
        map.close();
    }