DeleteOldOnAccessCache extends AbstractReportContentCache { @Override public void cleanup() { cleanUp(); } DeleteOldOnAccessCache( final ICacheBackend backend );  DeleteOldOnAccessCache(); void setDaysToLive( final long daysToLive ); @Override boolean put( final String key, final IReportContent value ); @Override boolean put( final String key, final IReportContent value,  Map<String, Serializable> metaData ); @Override IReportContent get( final String key ); @Override Map<String, Serializable> getMetaData( String key ); @Override void cleanup(); @Override void cleanupCurrentSession(); static final String TIMESTAMP; static final int MILLIS_IN_DAY; static final String ANONYMOUS; }
@Test public void testCleanup() throws Exception { final DeleteOldOnAccessCache cache = new DeleteOldOnAccessCache( fileSystemCacheBackend ); cache.setDaysToLive( 1L ); cache.put( SOME_KEY, SOME_VALUE ); assertNotNull( cache.get( SOME_KEY ) ); cache.setMillisToLive( 0 ); cache.cleanup(); Thread.sleep( 10 ); assertNull( cache.get( SOME_KEY ) ); }