I'm using OSCache in two places in my application. In one place, it is being used in code "manually" to cache images. This configuration specified a non-existent directory for the disk cache, which gets created and populated at runtime, very much as I'd expect.
In the other place, I'm using Hibernate EntityManager with OSCache as the second level cache. I'm providing a second properties for this purpose, so I can have seperate control over the caching. To avoid any clashes, I'm specifying an alternate directory.
This directory never gets created, nor populated, even if I turn memory caching off.
The logs indicate that they are using my alternate cache, but the settings don't seem to have any real effect.
If I disable the use of the non-Hibernate cache, the situation remains the same.
Hibernate version: Annotations: 3.3.1GA, EntityManager: 3.3.2GA
hibernate-oscache.properties:
Code:
cache.memory=false
cache.capacity=5
cache.unlimited.disk=true
cache.path=/tmp/foo/hb-cache
cache.persistence.overflow.only=true
cache.use.host.domain.in.key=true
hibernate.cfg.xml:
Code:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">@DB_DRIVER@</property>
<property name="hibernate.connection.username">@DB_USER@</property>
<property name="hibernate.connection.password">@DB_PASS@</property>
<property name="hibernate.connection.url">@DB_URL@</property>
<property name="hibernate.c3p0.min_size">30</property>
<property name="hibernate.c3p0.max_size">200</property>
<property name="hibernate.c3p0.idle_test_period">14400</property>
<property name="hibernate.cache.provider_class">com.opensymphony.oscache.hibernate.OSCacheProvider</property>
<property name="com.opensymphony.oscache.configurationResourceName">oscache-hibernate.properties</property>
<mapping class="com.foo.online.beans.datacontainer.Account"/>
<mapping class="com.foo.online.beans.datacontainer.AccountType"/>
<mapping class="com.foo.online.beans.datacontainer.Admin"/>
<mapping class="com.foo.online.beans.datacontainer.Customer"/>
<mapping class="com.foo.online.beans.datacontainer.Diagram"/>
<mapping class="com.foo.online.beans.datacontainer.DiagramShare"/>
<mapping class="com.foo.online.beans.datacontainer.DiagramVersion"/>
<mapping class="com.foo.online.beans.datacontainer.HostedTransaction"/>
<mapping class="com.foo.online.beans.datacontainer.Image"/>
<mapping class="com.foo.online.beans.datacontainer.Product"/>
<mapping class="com.foo.online.beans.datacontainer.OnlineUserBean"/>
<mapping class="com.foo.online.beans.datacontainer.Folder"/>
<class-cache class="com.foo.online.beans.datacontainer.AccountType" usage="read-only" />
<class-cache class="com.foo.online.beans.datacontainer.Product" usage="read-only" />
<class-cache class="com.foo.online.beans.datacontainer.Account" usage="read-write"/>
<class-cache class="com.foo.online.beans.datacontainer.Admin" usage="read-write"/>
<class-cache class="com.foo.online.beans.datacontainer.Customer" usage="read-write"/>
<class-cache class="com.foo.online.beans.datacontainer.Diagram" usage="read-write"/>
<class-cache class="com.foo.online.beans.datacontainer.DiagramShare" usage="read-write"/>
<class-cache class="com.foo.online.beans.datacontainer.DiagramVersion" usage="read-write"/>
<class-cache class="com.foo.online.beans.datacontainer.HostedTransaction" usage="read-write"/>
<class-cache class="com.foo.online.beans.datacontainer.Image" usage="read-write"/>
<class-cache class="com.foo.online.beans.datacontainer.OnlineUserBean" usage="read-write"/>
<class-cache class="com.foo.online.beans.datacontainer.Folder" usage="read-write"/>
</session-factory>
</hibernate-configuration>
log excerpt
Code:
2008-09-30 09:42:32,326 [main] INFO com.opensymphony.oscache.base.Config - OSCache: Properties read {cache.path=/tmp/foo.com/hb-cache, cache.persistence.overflow.only=true, cache.use.host.domain.in.key=true, cache.capacity=5, cache.memory=false, cache.unlimited.disk=true}
2008-09-30 09:42:32,332 [main] DEBUG com.opensymphony.oscache.base.Config - OSCache: Config called
2008-09-30 09:42:32,332 [main] DEBUG com.opensymphony.oscache.base.AbstractCacheAdministrator - Constructed AbstractCacheAdministrator()
2008-09-30 09:42:32,332 [main] INFO com.opensymphony.oscache.general.GeneralCacheAdministrator - Constructed GeneralCacheAdministrator()
2008-09-30 09:42:32,332 [main] INFO com.opensymphony.oscache.general.GeneralCacheAdministrator - Creating new cache
2008-09-30 09:42:32,351 [main] DEBUG com.opensymphony.oscache.hibernate.OSCacheProvider - OSCacheProvider started.
2008-09-30 09:42:32,400 [main] DEBUG com.opensymphony.oscache.hibernate.OSCacheProvider - building cache in OSCacheProvider...
2008-09-30 09:42:32,757 [main] DEBUG com.opensymphony.oscache.hibernate.OSCacheProvider - building cache in OSCacheProvider...
2008-09-30 09:42:32,807 [main] DEBUG com.opensymphony.oscache.hibernate.OSCacheProvider - building cache in OSCacheProvider...
2008-09-30 09:42:32,813 [main] DEBUG com.opensymphony.oscache.hibernate.OSCacheProvider - building cache in OSCacheProvider...
2008-09-30 09:42:32,855 [main] DEBUG com.opensymphony.oscache.hibernate.OSCacheProvider - building cache in OSCacheProvider...
2008-09-30 09:42:32,871 [main] DEBUG com.opensymphony.oscache.hibernate.OSCacheProvider - building cache in OSCacheProvider...
2008-09-30 09:42:32,877 [main] DEBUG com.opensymphony.oscache.hibernate.OSCacheProvider - building cache in OSCacheProvider...
2008-09-30 09:42:32,883 [main] DEBUG com.opensymphony.oscache.hibernate.OSCacheProvider - building cache in OSCacheProvider...
2008-09-30 09:42:32,890 [main] DEBUG com.opensymphony.oscache.hibernate.OSCacheProvider - building cache in OSCacheProvider...
2008-09-30 09:42:32,913 [main] DEBUG com.opensymphony.oscache.hibernate.OSCacheProvider - building cache in OSCacheProvider...
2008-09-30 09:42:32,920 [main] DEBUG com.opensymphony.oscache.hibernate.OSCacheProvider - building cache in OSCacheProvider...
2008-09-30 09:42:32,935 [main] DEBUG com.opensymphony.oscache.hibernate.OSCacheProvider - building cache in OSCacheProvider...
2008-09-30 09:42:32,947 [main] DEBUG com.opensymphony.oscache.hibernate.OSCacheProvider - building cache in OSCacheProvider...
2008-09-30 09:42:32,956 [main] DEBUG com.opensymphony.oscache.hibernate.OSCacheProvider - building cache in OSCacheProvider...
2008-09-30 09:42:32,978 [main] DEBUG com.opensymphony.oscache.hibernate.OSCacheProvider - building cache in OSCacheProvider...
2008-09-30 09:46:15,639 [TP-Processor43] DEBUG com.opensymphony.oscache.base.Config - OSCache: Config called
2008-09-30 09:46:15,668 [TP-Processor43] INFO com.opensymphony.oscache.base.Config - OSCache: Getting properties from URL file:/Applications/jakarta-tomcat-5.0.24/webapps/foo/WEB-INF/classes/oscache.properties for the default configuration
2008-09-30 09:46:15,669 [TP-Processor43] INFO com.opensymphony.oscache.base.Config - OSCache: Properties read {cache.algorithm=com.opensymphony.oscache.base.algorithm.LRUCache, cache.memory=false, cache.path=/tmp/foo.com/cache, cache.capacity=5, cache.persistence.class=com.opensymphony.oscache.plugins.diskpersistence.HashDiskPersistenceListener, cache.unlimited.disk=false, cache.use.host.domain.in.key=GLIFFY_DEV, cache.blocking=false, cache.persistence.overflow.only=false}
2008-09-30 09:46:15,669 [TP-Processor43] DEBUG com.opensymphony.oscache.base.AbstractCacheAdministrator - Constructed AbstractCacheAdministrator()
2008-09-30 09:46:15,669 [TP-Processor43] INFO com.opensymphony.oscache.general.GeneralCacheAdministrator - Constructed GeneralCacheAdministrator()
2008-09-30 09:46:15,669 [TP-Processor43] INFO com.opensymphony.oscache.general.GeneralCacheAdministrator - Creating new cache
Notice how the second configuration gets picked up later. Could this be overriding the initial configuration?!