Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.opencms.template.cache
Class CmsLruCache  view CmsLruCache download CmsLruCache.java

java.lang.Object
  extended bycom.opencms.template.cache.CmsLruCache

public class CmsLruCache
extends java.lang.Object

This class implements a LRU cache. It uses a Hashtable algorithm with the chaining method for collision handling. The sequence of the Objects is stored in an extra chain. Each object has a pointer to the previous and next object in this chain. If an object is inserted or used it is set to the tail of the chain. If an object has to be remouved it will be the head object. Only works with more than one element.

Version:
1.0

Nested Class Summary
(package private) static class CmsLruCache.CacheItem
           
 
Field Summary
private static boolean C_DEBUG
           
private  CmsLruCache.CacheItem head
           
private  CmsLruCache.CacheItem[] m_cache
           
private  int m_maxSize
           
private  int m_size
           
private  CmsLruCache.CacheItem tail
           
 
Constructor Summary
CmsLruCache(int size)
          Constructor
 
Method Summary
 void clearCache()
          Clears the cache completly.
 java.util.Vector deleteElementsAfterPublish()
          Deletes elements after publish.
 java.util.Vector deleteElementsByClass(java.lang.String className)
          Deletes all elements that depend on the class.
 java.util.Vector deleteElementsByTemplate(java.lang.String templateName)
          Deletes all elements that depend on the template.
 void deleteUri(java.lang.String uri)
          Deletes the uri from the Cache.
 java.lang.Object get(java.lang.Object key)
          returns the value to the key or null if the key is not in the cache.
 java.util.Vector getAllKeys()
          gets all keys in the cache.
 java.util.Vector getCacheInfo()
          Gets the Information of max size and size for the cache.
 java.util.Vector put(java.lang.Object key, java.lang.Object value)
          inserts a new object in the cache.
 void remove(java.lang.Object key)
          removes on item from the cache.
private  void removeFromTable(CmsLruCache.CacheItem oldItem)
          deletes one item from the cache.
private  void removeItem(CmsLruCache.CacheItem item)
          removes one item from the cache and from the sequence chain.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

C_DEBUG

private static final boolean C_DEBUG
See Also:
Constant Field Values

m_cache

private CmsLruCache.CacheItem[] m_cache

m_maxSize

private int m_maxSize

m_size

private int m_size

head

private CmsLruCache.CacheItem head

tail

private CmsLruCache.CacheItem tail
Constructor Detail

CmsLruCache

public CmsLruCache(int size)
Constructor

Method Detail

put

public java.util.Vector put(java.lang.Object key,
                            java.lang.Object value)
inserts a new object in the cache. If it is there already the value is updated.


get

public java.lang.Object get(java.lang.Object key)
returns the value to the key or null if the key is not in the cache. The found element has to line up behind the others (set to the tail).


remove

public void remove(java.lang.Object key)
removes on item from the cache.


removeFromTable

private void removeFromTable(CmsLruCache.CacheItem oldItem)
deletes one item from the cache. Not from the sequence chain.


removeItem

private void removeItem(CmsLruCache.CacheItem item)
removes one item from the cache and from the sequence chain.


deleteElementsByTemplate

public java.util.Vector deleteElementsByTemplate(java.lang.String templateName)
Deletes all elements that depend on the template. use only if the cache is for elements.


deleteElementsByClass

public java.util.Vector deleteElementsByClass(java.lang.String className)
Deletes all elements that depend on the class. use only if this cache is for elements.


deleteElementsAfterPublish

public java.util.Vector deleteElementsAfterPublish()
Deletes elements after publish. All elements that depend on the uri and all element that say so have to be removed. use only if this cache is for elements.


deleteUri

public void deleteUri(java.lang.String uri)
Deletes the uri from the Cache. Use only if this is the cache for uris.


clearCache

public void clearCache()
Clears the cache completly.


getCacheInfo

public java.util.Vector getCacheInfo()
Gets the Information of max size and size for the cache.


getAllKeys

public java.util.Vector getAllKeys()
gets all keys in the cache.