Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-1378

Provide LRU option for L2 data cache

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 2.1.0
    • datacache
    • 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.

      Attachments

        Activity

          People

            curtisr7 Richard G. Curtis
            to_rowe 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