MRUMemoryStore and Swapping under Apache Cocoon
http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Main
User Documentation

Concepts
Overview
Sitemap
Views
Caching
Actions
Matchers and Selectors
Entity Catalogs
MRUMemoryStore
Persistence
StoreJanitor
XMLSearching
XML Validation
Databases
Modules

Goal

This document explains how the MRUMemoryStore and Swapping under Cocoon executes.

Overview

The MRUMemoryStore was developed to provide a standard algorithm to store data in memory. For web-based applications the MRU (Most Recently Used) algorithm is very suitable, because the object most frequently accessed is always on "top".

If configured, the objects are also swapped to the filesystem if the MRUMemoryStore reached his configured max. object limit.

Implementation
MRUMemoryStore

The heart of the MRUMemoryStore ist combination of a LinkedList and a HashMap:

The LinkedList provides the queue mechanism, and the entries in the LinkedList contain the key to the data in the HashMap. When caching a new entry in to the list, the entry is inserted to the front of the list. If the list is already full, the oldest data entry is removed from the Cache. When requesting a entry, the store returns the object by key and inserts the requested key on the top of the Cache. This implementation keeps the most recent used objects in the store and provides the best use of the machines memory.

Swapping

When the MRUMemoryStore is full or the JVM is at the heap size limit the objects in the MRUMemoryStore are swapped to the Filesystem. The default directory is "cache-dir" in the work-directory.

NOTE: The keys under Cocoon are Strings at the moment. Therefor the filenames of the swapped objects can be very long. Especially Windows OS flavours have problems with long filenames. Use the JispFilesystemStore to get rid of it.

Configuration of the MRUMemoryStore in the cocoon.xconf
<store class="org.apache.cocoon.components.store.MRUMemoryStore"
       logger="core.store">
  <parameter name="maxobjects" value="100"/>
  <parameter name="use-persistent-cache" value="true"/>
</store>
  

Explanation of the paramters:

  1. <parameter name="maxobjects" value="100"/>: Indicates how many objects will be hold in MRUMemoryStore. When the number of maxobjects has been reached, the last object in the MRUMemoryStore will be thrown out.
  2. <parameter name="use-persistent-cache" value="true"/>: If this switch is set on true, objects are swapped out to the filesystem, if the MRUMemoryStore has reached his maximum object limit, or the JVM memory consumption is over the heap size limit. See StoreJanitor user docs for more information.
Copyright © 1999-2002 The Apache Software Foundation. All Rights Reserved.