/** * Gets the cache attribute of the CacheHub object * <p> * @param cacheName * @param cattr * @return CompositeCache */ public <K, V> CompositeCache<K, V> getCache( String cacheName, ICompositeCacheAttributes cattr ) { cattr.setCacheName( cacheName ); return getCache( cattr, this.defaultElementAttr ); }
/** * Gets the cache attribute of the CacheHub object * <p> * @param cacheName * @param cattr * @param attr * @return CompositeCache */ public <K, V> CompositeCache<K, V> getCache( String cacheName, ICompositeCacheAttributes cattr, IElementAttributes attr ) { cattr.setCacheName( cacheName ); return getCache( cattr, attr ); }
/** * Gets the cache attribute of the CacheHub object * <p> * @param cacheName * @param cattr * @param attr * @return CompositeCache */ public <K, V> CompositeCache<K, V> getCache( String cacheName, ICompositeCacheAttributes cattr, IElementAttributes attr ) { cattr.setCacheName( cacheName ); return getCache( cattr, attr ); }
/** * Gets the cache attribute of the CacheHub object * <p> * @param cacheName * @param cattr * @return CompositeCache */ public <K, V> CompositeCache<K, V> getCache( String cacheName, ICompositeCacheAttributes cattr ) { cattr.setCacheName( cacheName ); return getCache( cattr, getDefaultElementAttributes() ); }
/** * Setup a disk cache. Configure the disk usage pattern to not swap. Call spool. Verify that the * item is not put to disk. */ public void testSpoolNotAllowed() { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.UPDATE ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.spoolToDisk( inputElement ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 0, mock.updateCount ); }
/** * Setup a disk cache. Configure the disk usage pattern to SWAP. Call updateAuxiliaries. Verify * that the item is not put to disk. * <p> * This tests that the items are not put to disk on a normal put when the usage pattern is set * to SWAP. * <p> * @throws IOException */ public void testUpdateNotAllowed() throws IOException { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.SWAP ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.updateAuxiliaries( inputElement, true ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 0, mock.updateCount ); }
/** * Setup a disk cache. Configure the disk usage pattern to not swap. Call spool. Verify that the * item is not put to disk. */ public void testSpoolNotAllowed() { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.UPDATE ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.spoolToDisk( inputElement ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 0, mock.updateCount ); }
/** * Verify we try a disk aux on a getMatching call. * <p> * @throws IOException */ public void testGetMatching_NotOnDisk() throws IOException { // SETUP int maxMemorySize = 0; String cacheName = "testGetMatching_NotOnDisk"; String memoryCacheClassName = "org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache"; ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(cacheName); cattr.setMemoryCacheName( memoryCacheClassName ); cattr.setMaxObjects( maxMemorySize ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, Integer> cache = new CompositeCache<String, Integer>( cattr, attr ); MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<String, Integer>(); diskMock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, Integer>[] aux = new AuxiliaryCache[] { diskMock }; cache.setAuxCaches( aux ); // DO WORK cache.getMatching( "junk" ); // VERIFY assertEquals( "Wrong number of calls", 1, diskMock.getMatchingCallCount ); }
/** * Verify we try a disk aux on a getMatching call. * <p> * @throws IOException */ public void testGetMatching_NotOnDisk() throws IOException { // SETUP int maxMemorySize = 0; String cacheName = "testGetMatching_NotOnDisk"; String memoryCacheClassName = "org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache"; ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(cacheName); cattr.setMemoryCacheName( memoryCacheClassName ); cattr.setMaxObjects( maxMemorySize ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, Integer> cache = new CompositeCache<String, Integer>( cattr, attr ); MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<String, Integer>(); diskMock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, Integer>[] aux = new AuxiliaryCache[] { diskMock }; cache.setAuxCaches( aux ); // DO WORK cache.getMatching( "junk" ); // VERIFY assertEquals( "Wrong number of calls", 1, diskMock.getMatchingCallCount ); }
String memoryCacheClassName = "org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache"; ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(cacheName); cattr.setMemoryCacheName( memoryCacheClassName ); cattr.setMaxObjects( maxMemorySize );
String memoryCacheClassName = "org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache"; ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(cacheName); cattr.setMemoryCacheName( memoryCacheClassName ); cattr.setMaxObjects( maxMemorySize );
/** * Setup a disk cache. Configure the disk usage pattern to UPDATE. Call updateAuxiliaries. * Verify that the item is put to disk. * <p> * This tests that the items are put to disk on a normal put when the usage pattern is set * appropriately. * @throws IOException */ public void testUpdateAllowed() throws IOException { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.UPDATE ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.updateAuxiliaries( inputElement, true ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount ); assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem ); }
/** * Setup a disk cache. Configure the disk usage pattern to swap. Call spool. Verify that the * item is put to disk. */ public void testSpoolAllowed() { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.SWAP ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.spoolToDisk( inputElement ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount ); assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem ); }
/** * Setup a disk cache. Configure the disk usage pattern to UPDATE. Call updateAuxiliaries with * local only set to false. Verify that the item is put to disk. * <p> * This tests that the items are put to disk on a normal put when the usage pattern is set * appropriately. The local setting should have no impact on whether the item goes to disk. * <p> * @throws IOException */ public void testUpdateAllowed_localFalse() throws IOException { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.UPDATE ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.updateAuxiliaries( inputElement, false ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount ); assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem ); }
/** * Setup a disk cache. Configure the disk usage pattern to swap. Call spool. Verify that the * item is put to disk. */ public void testSpoolAllowed() { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.SWAP ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.spoolToDisk( inputElement ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount ); assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem ); }
/** * Setup a disk cache. Configure the disk usage pattern to UPDATE. Call updateAuxiliaries with * local only set to false. Verify that the item is put to disk. * <p> * This tests that the items are put to disk on a normal put when the usage pattern is set * appropriately. The local setting should have no impact on whether the item goes to disk. * <p> * @throws IOException */ public void testUpdateAllowed_localFalse() throws IOException { // SETUP ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.UPDATE ); IElementAttributes attr = new ElementAttributes(); CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr ); MockAuxCache<String, String> mock = new MockAuxCache<String, String>(); mock.cacheType = CacheType.DISK_CACHE; @SuppressWarnings("unchecked") AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock }; cache.setAuxCaches( auxArray ); ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" ); // DO WORK cache.updateAuxiliaries( inputElement, false ); // VERIFY assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount ); assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem ); }
cattr.setCacheName(CACHE_NAME); cattr.setDiskUsagePattern( ICompositeCacheAttributes.DiskUsagePattern.UPDATE );
attributes.setCacheName(cacheName); attributes.setMaxObjects( maxObjects ); attributes.setSpoolChunkSize( 1 );
attributes.setCacheName(cacheName); attributes.setMaxObjects( maxObjects ); attributes.setSpoolChunkSize( 1 );
attributes.setCacheName(cacheName); attributes.setMaxObjects( maxObjects ); attributes.setSpoolChunkSize( 1 );