openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas O Rowe (JIRA)" <>
Subject [jira] Created: (OPENJPA-1378) Provide LRU option for L2 data cache
Date Sun, 08 Nov 2009 16:37:32 GMT
Provide LRU option for L2 data cache

                 Key: OPENJPA-1378
             Project: OpenJPA
          Issue Type: Improvement
          Components: datacache
            Reporter: Thomas O Rowe
            Priority: Minor

Default data cache operation when it is full is to randomly toss an entity.  For queries that
return >1 entity, this means the most recent query is not guaranteed to be cached in its

Jeremy provided this code to me which certainly works, and should be integrated into the base
data cache support...

1) Create a new plugin class:  (bundle it with your test app)

package test;

import org.apache.openjpa.datacache.AbstractDataCache;
import org.apache.openjpa.datacache.ConcurrentDataCache;
import org.apache.openjpa.util.CacheMap;

public class TomsCache extends ConcurrentDataCache {

    protected CacheMap newCacheMap() {
        return new CacheMap(true, 1000) {
            protected void entryRemoved(Object key, Object value,
                boolean expired) {
                keyRemoved(key, expired);

2) Enable your plugin using a persistence property.

  <property name="openjpa.DataCache" value="test.TomsCache(CacheSize=5, SoftReferenceSize=0)"/>

The oldest entry should get evicted first.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message