public synchronized void closeCache() {
        
        /* Return if the cache isn't open. */
        if(!m_IsCacheOpen)
            return;
        
        if(LOG.isError()) {
            LOG.error("SecondaryCache.closeCache()", " ActivePage= "+m_CurrentPageNumber+" offset= "+m_CurrentOffset);
        }
        
        long time = System.currentTimeMillis();
        
        try {
            /* Write the current data to cache */
            if(dout != null) {
                m_CacheHandler.writeOutputStreamToCache(dout, m_CurrentPageNumber);
                dout.close();
            }
            
            /* Write the index table to cache. */           
            m_CacheHandler.writeIndexTableToCache(m_CurrentPageNumber, m_NbrOfEntrysPage[m_CurrentPageNumber], m_IndexTableHashtable);
            
            /* Update the info file with information about the current active
             * page and offset*/
            m_CacheHandler.updateCacheInfoFile(m_CurrentPageNumber, CACHE_VERSION);
            
            /* Close the cache. */
            m_CacheHandler.internalCloseCache();
            
        } catch (Exception e) {
            if(LOG.isError()) {
                LOG.error("SecondaryCache.closeCache()", e);
            }
        }       

        if(LOG.isInfo()) {
            LOG.info("SecondaryCache.closeCache()", "time= "+(System.currentTimeMillis()-time)+" ms");
        }
    }