-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: RO cache, manually refreshed and selectively overridden?
PostPosted: Wed Feb 21, 2007 1:05 pm 
Newbie

Joined: Tue Sep 20, 2005 3:51 pm
Posts: 18
Location: Boston, MA
Hello all,
Two questions:

1. How do I manually refresh ehcache?

2. Is there an intelligent way to set a
Code:
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
element to READ_WRITE for the scope of a single transaction?

I am a developer on a very large project with 20 nodes in the cluster and 30 entities in the domain model (Hibernate 3.2, Tomcat 5.5, JDK5). Like most applications I've worked with, the vast majority of our data is read-only 99% of the time. Think of it as an e-commerce application. The merchandise is read-only until updated by a feed, perhaps once a week.

Under the assumption that a read-only cache is more cluster friendly and performs faster with less overhead, wouldn't the ideal be to set the read-only attribute at query time and make it writable only when the feed executes, manually updating the cache afterwards?

I assume this solves clustering issues since the db is never updated by any other process. I assume EHCache is lighter and more responsive than a cluster-aware cache. I also assume that READ_ONLY will perform faster than READ_WRITE. Ideally, I'd not like to maintain 2 complete sets of mappings, but instead the delta between them (assuming there's no programmatic way of doing so).

I've tried a few approaches with no success.
Approach 1: override at the session
First of all, I tried setting an entity to
Code:
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
and making it writable using
Code:
session.setCacheMode(CacheMode.IGNORE)
during the session I was attempting to write to the entity. It didn't override the READ_ONLY attribute.

Approach 2: Inheritance.
If I can't programmatically override the caching READ_ONLY attribute, I'd be happy to extends each class and create a read/write instance of each class if it meant not duplicating any unnecessary mapping elements.

I tried creating an entity named ItemRO which works great, but
Code:
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
ItemRW extends ItemRO{
}

is not an option. I assume there's no simple way to extend the working class and change one property.

Thanks in advance,
Steven


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.