| Author |
Message |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 11/03/2009 08:25:55
|
velo
neo
Joined: 11/03/2009 08:18:46
Messages: 4
Offline
|
Hi,
We are using ehcache at nexus, and we wanna use it w/o touching the disk.
So far I'm having no success with this configuration:
Code:
<ehcache>
<diskStore path="${runtime}/tmp/ehcache"/>
<defaultCache
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LFU"
/>
<cache name="path-cache"
maxElementsInMemory="100000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LFU"
/>
</ehcache>
I assume that setting diskPersistent and overflowToDisk as false would be enough, but it does still storing files to disk..
2009-11-03 13:33:38,262 INFO [org.jsecurity.cache.ehcache.EhCacheManager] - Could not find a specific ehcache configuration for cache named [jsecurity-activeSessionCache]; using defaults.
2009-11-03 13:33:38,262 INFO [org.jsecurity.cache.ehcache.EhCacheManager] - Creating jsecurity-activeSessionCache cache with default JSecurity session cache settings.
2009-11-03 13:33:38,341 DEBUG [net.sf.ehcache.config.DiskStoreConfiguration] - Disk Store Path: C:\Users\Seven\AppData\Local\Temp\
2009-11-03 13:33:38,341 DEBUG [net.sf.ehcache.config.DiskStoreConfiguration] - Disk Store Path: C:\Users\Seven\AppData\Local\Temp\
2009-11-03 13:33:38,341 WARN [net.sf.ehcache.Cache] - An API change between ehcache-1.1 and ehcache-1.2 results in the persistence path being set to C:\Users\Seven\AppData\Local\Temp\ when the ehcache-1.1 constructor is used. Please change to the 1.2 constructor.
2009-11-03 13:33:38,346 DEBUG [net.sf.ehcache.store.DiskStore] - IOException reading index. Creating new index.
2009-11-03 13:33:38,346 DEBUG [net.sf.ehcache.store.DiskStore] - Index file S:\nexus-test-harness-launcher-2914\target\nexus\nexus-webapp-1.4.1-SNAPSHOT\runtime\tmp\ehcache\jsecurity-activeSessionCache.index deleted.
Right now I'm using ehcache 1.5.0, but I have tried 1.6.0 and 1.6.2.
Any clue what am I doing wrong?
VELO
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 11/03/2009 21:13:14
|
gluck
qaestor
Joined: 09/15/2009 18:01:23
Messages: 179
Location: Brisbane, Australia
Offline
|
I have just checked the source.
/**
* Whether this cache uses a disk store
*
* @return true if the cache either overflows to disk or is disk persistent
*/
protected boolean isDiskStore() {
return configuration.isOverflowToDisk() || configuration.isDiskPersistent();
}
It only creates the disk store if isDiskStore returns true.
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 11/03/2009 21:16:20
|
gluck
qaestor
Joined: 09/15/2009 18:01:23
Messages: 179
Location: Brisbane, Australia
Offline
|
Can you try 1.7?
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 11/04/2009 04:10:53
|
velo
neo
Joined: 11/03/2009 08:18:46
Messages: 4
Offline
|
Cool, it does work on 1.7....
FWIW, chaging maven dependency type from jar to pom does introduce some problems.... specially because maven won't bump old versions to 1.7.... I do now have to manually exclude all 1.5 references.
VELO
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 11/04/2009 05:43:25
|
velo
neo
Joined: 11/03/2009 08:18:46
Messages: 4
Offline
|
Ops, my bad, a configuration file was changed to write ehcache config in another place.... so it did looked as passed, but no, still with problems.
VELO
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 11/04/2009 16:41:23
|
gluck
qaestor
Joined: 09/15/2009 18:01:23
Messages: 179
Location: Brisbane, Australia
Offline
|
Ok, I have extended the test which verifies this.
/**
* Ehcache 1.5 allows the diskStore element to be optional. Check that is is null
* Add different cache constructors to make sure none inadvertently create a disk store
*/
@Test
public void testCacheManagerWithNoDiskCachesFromConfiguration() throws CacheException, InterruptedException {
LOG.info(System.getProperty("java.io.tmpdir"));
singletonManager = CacheManager.create(AbstractCacheTest.TEST_CONFIG_DIR + "ehcache-nodisk.xml");
singletonManager.addCache("jsecurity-activeSessionCache");
Cache cacheA = singletonManager.getCache("jsecurity-activeSessionCache");
Cache cacheB = new Cache("1", 10, false, false, 2, 2);
singletonManager.addCache(cacheB);
Cache cacheC = new Cache("2", 10, false, false, 2, 2, false, 100);
singletonManager.addCache(cacheC);
for(int i = 0; i < 100; i++) {
cacheA.put(new Element(i + "", "dog"));
cacheB.put(new Element(i + "", "dog"));
cacheC.put(new Element(i + "", "dog"));
}
singletonManager.shutdown();
assertEquals(null, singletonManager.getDiskStorePath());
}
None of this creates a disk store.
I notice you are using JSecurity, which is what is creating your cache.
Your problem is in the EhCacheManager in shiro (was called JSecurity):
/**
* Builds the default cache instance to use for Shiro's Session Cache when enterprise Sessions are
* enabled.
*
* @return the default cache instance to use for Shiro's Session Cache when enterprise Sessions are
* enabled.
* @throws CacheException if there is a problem constructing the Cache instance.
*/
private net.sf.ehcache.Cache buildDefaultActiveSessionsCache() throws CacheException {
return new net.sf.ehcache.Cache(DEFAULT_ACTIVE_SESSIONS_CACHE_NAME,
DEFAULT_ACTIVE_SESSIONS_CACHE_MAX_ELEM_IN_MEM,
true,
true,
0,
0,
true,
DEFAULT_ACTIVE_SESSIONS_DISK_EXPIRY_THREAD_INTERVAL_SECONDS);
}
It is creating default caches with true for overflowToDisk.
Looking at the code, if you simply configure a cache in ehcache.xml called jsecurity-activeSessionCache it will skip creating using defaults. That will then fix your problem.
Tell Jason he owes me one. He will know what that means :)
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 11/05/2009 10:33:02
|
velo
neo
Joined: 11/03/2009 08:18:46
Messages: 4
Offline
|
Thanks, now it really worked =D
I tell Jason once I saw him.
VELO
|
|
|
 |
![[Post New]](/forums/templates/default/images/icon_minipost_new.gif) 07/17/2011 23:54:31
|
rajoshi
seraphim
Joined: 07/04/2011 04:36:10
Messages: 1481
Offline
|
issue seems to be resolved .Please let know in case of more information.
|
Rakesh Joshi
Senior Consultant
Terracotta. |
|
|
 |
|
|