Announcement Announcement Module
No announcement yet.
Getting 2 cache hits instead of one? (ehCache) Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting 2 cache hits instead of one? (ehCache)

    Why I get 2 cache hits with the following code? Shouldn't it be one?
    I'm using SingletonEhCacheProvider, because if I use EhCacheProvider I get a 1 put, 1 miss, 0 hits, even though my log messages says "item was already cached"

    	public void exampleSet() {
    		ExampleSet expectedExampleSet = new ExampleSet("string1");;		
    Some logging info
    Hibernate: insert into ExampleSet (element, id) values (?, ?)
    [ReadWriteCache]: Inserting: example.pojo.ExampleSet#67
    [EhCache]: key: example.pojo.ExampleSet#67
    [Cache]: example.pojo.ExampleSet cache - Miss
    [EhCache]: Element for example.pojo.ExampleSet#67 is null
    [ReadWriteCache]: Inserted: example.pojo.ExampleSet#67
    [ReadWriteCache]: Cache lookup: example.pojo.ExampleSet#67
    [EhCache]: key: example.pojo.ExampleSet#67
    [ReadWriteCache]: Cached item was locked: example.pojo.ExampleSet#67
    Hibernate: select as id1_0_, exampleset0_.element as element1_0_ from ExampleSet exampleset0_ where
    [ReadWriteCache]: Caching: example.pojo.ExampleSet#67
    [EhCache]: key: example.pojo.ExampleSet#67
    [ReadWriteCache]: Item was already cached: example.pojo.ExampleSet#67
    [  name = example.pojo.ExampleSet cacheHits = 2 onDiskHits = 0 inMemoryHits = 2 misses = 1 size = 1 ]
    Last edited by icetbr; Aug 7th, 2008, 10:33 AM.

  • #2
    Actually this behaviour is wrong, when I extend AbstractJpaTests, statistics works fine.

    I was trying to use the Junit4 approach, but it's too much trouble. If anyone has successfuly replaced the use of AbstractJpaTests in favor of Junit4 annotations, please let me know


    • #3
      Any luck with Junit 4 approach to test 2nd level cache ?


      I'm using AbstractTransactionalJUnit4SpringContextTests however have problem isolating the issue of what's not working for my 2nd level cache with hibernate and ehcache ... has anyone reply to you yet ?



      • #4
        Nop sorry. I've gave up trying for now