ICacheElement<K, V> element = processGet(key); if (element != null)
ICacheElement<K, V> element = processGet( key ); if ( element != null )
ICacheElement<String, String> element = disk.processGet( i + ":key" ); assertNotNull( "Shoulds have received an element.", element ); ICacheElement<String, String> element = disk.processGet( i + ":key" ); assertNull( "Should not have received an element.", element );
ICacheElement<String, String> element = disk.processGet("key:" + i); assertNotNull("Should have received an element.", element); assertEquals("Element is wrong.", "data:" + i, element.getVal());
ICacheElement<String, String> element = disk.processGet( "key:" + i ); assertNotNull( "Should have received an element.", element ); assertEquals( "Element is wrong.", "data:" + i, element.getVal() );
ICacheElement<String, String> element = disk.processGet(i + ":key"); assertNotNull("Shoulds have received an element.", element); ICacheElement<String, String> element = disk.processGet(i + ":key"); assertNull("Should not have received an element.", element);
/** * Verify the item makes it to disk. * <p> * * @throws IOException */ public void testProcessUpdate_Simple() throws IOException { // SETUP String cacheName = "testProcessUpdate_Simple"; IndexedDiskCacheAttributes cattr = getCacheAttributes(); cattr.setCacheName(cacheName); cattr.setMaxKeySize(100); cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest"); IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<String, String>(cattr); String key = "myKey"; String value = "myValue"; ICacheElement<String, String> ce = new CacheElement<String, String>(cacheName, key, value); // DO WORK diskCache.processUpdate(ce); ICacheElement<String, String> result = diskCache.processGet(key); // VERIFY assertNotNull("Should have a result", result); long fileSize = diskCache.getDataFileSize(); assertTrue("File should be greater than 0", fileSize > 0); }
/** * Verify the item makes it to disk. * <p> * @throws IOException */ public void testProcessUpdate_Simple() throws IOException { // SETUP String cacheName = "testProcessUpdate_Simple"; IndexedDiskCacheAttributes cattr = getCacheAttributes(); cattr.setCacheName( cacheName ); cattr.setMaxKeySize( 100 ); cattr.setDiskPath( "target/test-sandbox/IndexDiskCacheUnitTest" ); IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<String, String>( cattr ); String key = "myKey"; String value = "myValue"; ICacheElement<String, String> ce = new CacheElement<String, String>( cacheName, key, value ); // DO WORK diskCache.processUpdate( ce ); ICacheElement<String, String> result = diskCache.processGet( key ); // VERIFY assertNotNull( "Should have a result", result ); long fileSize = diskCache.getDataFileSize(); assertTrue( "File should be greater than 0", fileSize > 0 ); }
ICacheElement<GroupAttrName<String>, String> element = disk.processGet( groupAttrName ); assertNotNull( "Should have received an element.", element ); ICacheElement<GroupAttrName<String>, String> element = disk.processGet( groupAttrName );
ICacheElement<GroupAttrName<String>, String> element = disk.processGet(groupAttrName); assertNotNull("Should have received an element.", element); ICacheElement<GroupAttrName<String>, String> element = disk.processGet(groupAttrName);
ICacheElement<String, String> element = disk.processGet( "key:" + i ); assertNotNull( "presave, Should have received an element.", element ); assertEquals( "presave, element is wrong.", "data:" + i, element.getVal() ); ICacheElement<String, String> element = disk.processGet( "key:" + i ); assertNotNull( "postsave, Should have received an element.", element ); assertEquals( "postsave, element is wrong.", "data:" + i, element.getVal() );
ICacheElement<String, String> element = disk.processGet( "key:" + i ); assertNotNull( "presave, Should have received an element.", element ); assertEquals( "presave, element is wrong.", "data:" + i, element.getVal() ); ICacheElement<String, String> element = disk.processGet( "key:" + i ); assertNotNull( "postsave, Should have received an element.", element ); assertEquals( "postsave, element is wrong.", "data:" + i, element.getVal() );
/** * Add some items to the disk cache and then remove them one by one. * @throws IOException */ public void testRemoveItems() throws IOException { IndexedDiskCacheAttributes cattr = getCacheAttributes(); cattr.setCacheName( "testRemoveItems" ); cattr.setMaxKeySize( 100 ); cattr.setDiskPath( "target/test-sandbox/IndexDiskCacheUnitTest" ); IndexedDiskCache<String, String> disk = new IndexedDiskCache<String, String>( cattr ); disk.processRemoveAll(); int cnt = 25; for ( int i = 0; i < cnt; i++ ) { IElementAttributes eAttr = new ElementAttributes(); eAttr.setIsSpool( true ); ICacheElement<String, String> element = new CacheElement<String, String>( "testRemoveItems", "key:" + i, "data:" + i ); element.setElementAttributes( eAttr ); disk.processUpdate( element ); } // remove each for ( int i = 0; i < cnt; i++ ) { disk.remove( "key:" + i ); ICacheElement<String, String> element = disk.processGet( "key:" + i ); assertNull( "Should not have received an element.", element ); } }
/** * Add some items to the disk cache and then remove them one by one. * * @throws IOException */ public void testRemoveItems() throws IOException { IndexedDiskCacheAttributes cattr = getCacheAttributes(); cattr.setCacheName("testRemoveItems"); cattr.setMaxKeySize(100); cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest"); IndexedDiskCache<String, String> disk = new IndexedDiskCache<String, String>(cattr); disk.processRemoveAll(); int cnt = 25; for (int i = 0; i < cnt; i++) { IElementAttributes eAttr = new ElementAttributes(); eAttr.setIsSpool(true); ICacheElement<String, String> element = new CacheElement<String, String>("testRemoveItems", "key:" + i, "data:" + i); element.setElementAttributes(eAttr); disk.processUpdate(element); } // remove each for (int i = 0; i < cnt; i++) { disk.remove("key:" + i); ICacheElement<String, String> element = disk.processGet("key:" + i); assertNull("Should not have received an element.", element); } }
ICacheElement<String, String> result = diskCache.processGet( key );
ICacheElement<String, String> result = diskCache.processGet( key );
ICacheElement<String, String> result = diskCache.processGet(key);
ICacheElement<String, String> result = diskCache.processGet(key);
ICacheElement<String, String> result = diskCache.processGet( key );
ICacheElement<String, String> result = diskCache.processGet(key);