Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Database primary keys as cache keys?

CharlesCoatesJan 15 2010 — edited Jan 19 2010
I am planning to use Coherence initially to provide basic caches that sit in front of database tables. I plan to implement various CacheStores that will execute the db code and create the objects that will sit in those caches.

I am trying to figure out what the best approach would be for designing the cache keys. An obvious choice would be to use the database primary keys. But this has drawbacks. It will require the application to know the primary key before it asks the cache for a particular object. This is not really a new problem, but the introduction of Coherence may open up some new options in solving this.

Using db primary keys as cache keys also adds complication when new objects are created. The applicaiton will create the object and put it in the cache. The put operation will call down to the store method of the CacheStore. At this point, no primary key has been created yet for the object. A primary key will not be created until the db code is executed. At which point, the key in the cache must be changed.

Is there a well-designed approach to solving this problem? Should db primary keys not be used as cache keys? If not, what are some other good options for cache keys?

Any ideas? Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 16 2010
Added on Jan 15 2010
5 comments
1,915 views