@ Override public synchronized void run ( ) { Date now = new Date ( ) ; if ( ! cache . isEmpty ( ) && ( ( cache . size ( ) > cacheSize - 1 ) || ( now . getTime ( ) - lastCacheAccess . getTime ( ) > cacheMillis ) ) ) { try { flush ( ) ; } catch ( RepositoryException e ) { log . error ( e . getLocalizedMessage ( ) ) ; throw new RuntimeException ( e ) ; } catch ( MalformedQueryException e ) { log . error ( e . getLocalizedMessage ( ) ) ; throw new RuntimeException ( e ) ; } catch ( UpdateExecutionException e ) { log . error ( e . getLocalizedMessage ( ) ) ; throw new RuntimeException ( e ) ; } catch ( IOException e ) { log . error ( e . getLocalizedMessage ( ) ) ; throw new RuntimeException ( e ) ; } } }
tests to see if we should flush cache