JdbcInventory extends JdbcHelper implements Inventory { @Override public void cleanup() { try ( Connection connection = config.getConnection(); Statement stmt = connection.createStatement() ) { stmt.executeUpdate("DELETE FROM Inventory WHERE expires < " + now(-5 * MINUTE)); } catch (SQLException e) { LOG.debug(e.getMessage(), e); } for (Map<InventoryVector, Long> c : cache.values()) { c.entrySet().removeIf(e -> e.getValue() < now(-5 * MINUTE)); } } JdbcInventory(JdbcConfig config); @Override List<InventoryVector> getInventory(long... streams); @Override List<InventoryVector> getMissing(List<InventoryVector> offer, long... streams); @Override ObjectMessage getObject(InventoryVector vector); @Override List<ObjectMessage> getObjects(long stream, long version, ObjectType... types); @Override void storeObject(ObjectMessage object); @Override boolean contains(ObjectMessage object); @Override void cleanup();  }
@Test public void testCleanup() throws Exception { assertNotNull(inventory.getObject(inventoryVectorIgnore)); inventory.cleanup(); assertNull(inventory.getObject(inventoryVectorIgnore)); }