Hello.
I want to use EHCache 1.1 with Hibernate 2.1.
I created the ehcache.xml file where I added the object I wanted to be cached :
<cache name="Test"
maxElementsInMemory="15000"
eternal="true"
overflowToDisk="true"
/>
In the Test.hbm.xml object file I added :
<cache usage="read-write" />
Also in hibernate.properties I have :
hibernate.cache.use_query_cache true
hibernate.cache.provider_class net.sf.ehcache.hibernate.Provider
I also set an entry in my log4j.xml to have a ehcache.log file.
I want to get all Test objects (about 14000 elements) and add them to a JComboBox. Practically, I click a button and a new dialog which contains the combobox is displayed. I start my server and my client applications.
At first load on my combobox in ehcache.log file I have entries like following :
--------------------
key: 1
2005-08-29 17:35:51,015 DEBUG [net.sf.ehcache.store.MemoryStore] Test: MemoryStore miss for 1
2005-08-29 17:35:51,015 DEBUG [net.sf.ehcache.Cache] Test cache - Miss
2005-08-29 17:35:51,015 DEBUG [net.sf.ehcache.hibernate.Plugin] Element for 1 is null
2005-08-29 17:35:51,031 DEBUG [net.sf.ehcache.Cache] Test: Is element with key 1 expired?: false
---------------------
At second load on my combobox (client is not closed) I have entries like :
---------------------
key: 1
2005-08-29 17:36:33,484 DEBUG [net.sf.ehcache.store.MemoryStore] Test: MemoryStore hit for 1
2005-08-29 17:36:33,484 DEBUG [net.sf.ehcache.Cache] Test: Is element with key 1 expired?: false
---------------------
So it seems the cache works, because all elements are marked with "hit" in the log for the second access. But the time for first and second loads are the same (about 20 seconds - the time is measured on the server for the method which gets all the objects from database).
Is there something I am missing? From the log I can see the cache is working, but from the loading times I can see it doesn't.
Please help me if you heard about such behaviour.
Mike
|