OpenJPA
  1. OpenJPA
  2. OPENJPA-1378

Provide LRU option for L2 data cache

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.1.0
    • Component/s: datacache
    • Labels:
      None

      Description

      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 entirety.

      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.

        Activity

        Hide
        Rick Curtis added a comment -

        Committed revision 964097 to trunk.

        Show
        Rick Curtis added a comment - Committed revision 964097 to trunk.
        Hide
        Michael Dick added a comment -

        Closing issues which have been resolved for some time. If the problem persists, please reopen.

        Show
        Michael Dick added a comment - Closing issues which have been resolved for some time. If the problem persists, please reopen.

          People

          • Assignee:
            Rick Curtis
            Reporter:
            Thomas O Rowe
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 24h
              24h
              Remaining:
              Remaining Estimate - 24h
              24h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development