## org.exist.storage.cache
Class LRDCache

    java.lang.Object
      org.exist.storage.cache.GClockCache
          org.exist.storage.cache.LRDCache

All Implemented Interfaces:
  Cache

Direct Known Subclasses:
  CollectionCache

public class LRDCache
extends GClockCache

A cache implementation based on a Least Reference Density (LRD) replacement policy. The class maintains a global reference counter, containing the sum of all references in the cache. Each object has a timestamp, which is equal to the number of global references at the time, the object has been added to the cache. If the cache is full, the object with the least reference density is removed. The reference density is computed as the ratio between the object's reference counter and the number of references added since the object has been included into the cache, i.e. RC(i) / (GR - TS(i)).

Author:
  wolf

Field Summary

Fields inherited from interface org.exist.storage.cache.Cache
`LOG`

Constructor Summary
`LRDCache(int size, double growthFactor, double growthThreshold)`

Method Summary
`void` `add(Cacheable item, int initialRefCount)` Add the item to the cache.

Methods inherited from class org.exist.storage.cache.GClockCache
`add, flush, get, get, getBuffers, getFails, getFileName, getGrowthFactor, getHits, getLoad, getThrashing, getUsedBuffers, hasDirtyItems, remove, resize, setCacheManager, setFileName`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### LRDCache

    public LRDCache(int size,
                    double growthFactor,
                    double growthThreshold)

Method Detail

### add

    public void add(Cacheable item,
                    int initialRefCount)

  Description copied from interface: `Cache`
  Add the item to the cache. If it is already in the cache, update the references.

  Specified by:
    `add` in interface `Cache`
  Overrides:
    `add` in class `GClockCache`

Copyright (C) Wolfgang Meier. All rights reserved.