throws Exception
{
int items = 300000;
String region = "testCache1";
JCS jcs = JCS.getInstance( region );
try
{
System.out.println( "Start: " + measureMemoryUse() );
// Add items to cache
for ( int i = 0; i <= items; i++ )
{
jcs.put( i + ":key", region + " data " + i );
}
System.out.println( jcs.getStats() );
System.out.println( "--------------------------" );
System.out.println( "After put: " + measureMemoryUse() );
Thread.sleep( 5000 );
System.out.println( jcs.getStats() );
System.out.println( "--------------------------" );
System.out.println( "After wait: " + measureMemoryUse() );
// Test that all items are in cache
for ( int i = 0; i <= items; i++ )
{
String value = (String) jcs.get( i + ":key" );
assertEquals( region + " data " + i, value );
}
System.out.println( "After get: " + measureMemoryUse() );
// // Remove all the items
// for ( int i = 0; i <= items; i++ )
// {
// jcs.remove( i + ":key" );
// }
//
// // Verify removal
// for ( int i = 0; i <= items; i++ )
// {
// assertNull( "Removed key should be null: " + i + ":key" + "\n
// stats " + jcs.getStats(), jcs.get( i + ":key" ) );
// }
}
finally
{
// dump the stats to the report
System.out.println( jcs.getStats() );
System.out.println( "--------------------------" );
System.out.println( "End: " + measureMemoryUse() );
}
}