&引用;无法删除[Class]的磁盘存储项;在Grails中-如何禁用基于磁盘的缓存?
我在Grails应用程序中遇到以下异常:&引用;无法删除[Class]的磁盘存储项;在Grails中-如何禁用基于磁盘的缓存?,grails,ehcache,Grails,Ehcache,我在Grails应用程序中遇到以下异常: [1564928] store.DiskStore ClassNameCache: Could not remove disk store entry for ClassName#123195371. Error was null java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2297)
[1564928] store.DiskStore ClassNameCache: Could not remove disk store entry for ClassName#123195371. Error was null
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2297)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2766)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:797)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:297)
at net.sf.ehcache.store.DiskStore$1.<init>(DiskStore.java:316)
at net.sf.ehcache.store.DiskStore.loadElementFromDiskElement(DiskStore.java:316)
at net.sf.ehcache.store.DiskStore.expireElements(DiskStore.java:973)
at net.sf.ehcache.store.DiskStore.throwableSafeExpireElementsIfRequired(DiskStore.java:657)
at net.sf.ehcache.store.DiskStore.spoolAndExpiryThreadMain(DiskStore.java:645)
at net.sf.ehcache.store.DiskStore.access$900(DiskStore.java:68)
at net.sf.ehcache.store.DiskStore$SpoolAndExpiryThread.run(DiskStore.java:1110)
似乎当前的缓存设置正在写入/tmp/tomcat6 tmp/
我想完全禁用磁盘缓存,而只缓存到内存。怎么做?如果类路径中没有ehcache.xml文件,ehcache将使用其默认设置。但如果您确实有一个(放在grails app/conf或src/java中),那么将使用它。上的示例有很好的文档记录 这样的事情应该行得通;调整未显式声明的缓存的默认缓存设置(尽管为了文档起见,我更愿意创建它们),并定义任何具有非默认设置的特定缓存:
<ehcache>
<diskStore path='java.io.tmpdir' />
<defaultCache
maxElementsInMemory='10000'
eternal='false'
timeToIdleSeconds='120'
timeToLiveSeconds='120'
overflowToDisk='true'
maxElementsOnDisk='10000000'
diskPersistent='false'
diskExpiryThreadIntervalSeconds='120'
memoryStoreEvictionPolicy='LRU'
/>
<cache name='com.yourcompany.yourapp.DomainClassName'
maxElementsInMemory='1000'
overflowToDisk='false'
/>
<!-- hibernate stuff -->
<cache name='org.hibernate.cache.StandardQueryCache'
maxElementsInMemory='50'
eternal='false'
timeToLiveSeconds='120'
maxElementsOnDisk='0'
/>
<cache name='org.hibernate.cache.UpdateTimestampsCache'
maxElementsInMemory='5000'
eternal='true'
maxElementsOnDisk='0'
/>
</ehcache>
将两个Hibernate缓存放在其中也是一个好主意,这样就可以根据需要方便地调整它们
<ehcache>
<diskStore path='java.io.tmpdir' />
<defaultCache
maxElementsInMemory='10000'
eternal='false'
timeToIdleSeconds='120'
timeToLiveSeconds='120'
overflowToDisk='true'
maxElementsOnDisk='10000000'
diskPersistent='false'
diskExpiryThreadIntervalSeconds='120'
memoryStoreEvictionPolicy='LRU'
/>
<cache name='com.yourcompany.yourapp.DomainClassName'
maxElementsInMemory='1000'
overflowToDisk='false'
/>
<!-- hibernate stuff -->
<cache name='org.hibernate.cache.StandardQueryCache'
maxElementsInMemory='50'
eternal='false'
timeToLiveSeconds='120'
maxElementsOnDisk='0'
/>
<cache name='org.hibernate.cache.UpdateTimestampsCache'
maxElementsInMemory='5000'
eternal='true'
maxElementsOnDisk='0'
/>
</ehcache>