## org.exist.storage.cache
Class Accounting

    java.lang.Object
      org.exist.storage.cache.Accounting

public class Accounting
extends java.lang.Object

Keeps track of various cache parameters. Most important, this class is used to determine if a cache should be grown by computing the cache efficiency, which is expressed as the amount of trashing that occurs during a certain period of time. Trashing occurs if a page is replaced from the cache and is reloaded shortly after. For the B+-tree pages, we normally don't want any trashing at all.

Author:
  wolf

Constructor Summary
`Accounting(double thrashingFactor)`

Method Summary
`int` `getHits()` Returns the number of total cache hits during the lifetime of the cache.
`int` `getMisses()` Returns the number of total cache faults.
`int` `getThrashing()` Return the current amount of trashing.
`void` `hitIncrement()` Increment the number of total cache hits by one.
`void` `missesIncrement()` Increment the number of total cache faults by one.
`void` `replacedPage(Cacheable cacheable)` Called by the cache to signal that a page was replaced in order to store the Cacheable object passed.
`void` `reset()`
`boolean` `resizeNeeded()` Returns true if a cache resize would increase the cache efficiency.
`void` `setTotalSize(int totalSize)` Set the current size of the cache.
`void` `stats()`

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

Constructor Detail

### Accounting

    public Accounting(double thrashingFactor)

Method Detail

### setTotalSize

    public void setTotalSize(int totalSize)

  Set the current size of the cache. Should be called by the cache whenever it changes its size.

  Parameters:
    `totalSize` -

### hitIncrement

    public void hitIncrement()

  Increment the number of total cache hits by one.

### getHits

    public int getHits()

  Returns the number of total cache hits during the lifetime of the cache.

  Returns:
    number of total cache hits

### missesIncrement

    public void missesIncrement()

  Increment the number of total cache faults by one.

### getMisses

    public int getMisses()

  Returns the number of total cache faults.

  Returns:
    number of total cache faults

### replacedPage

    public void replacedPage(Cacheable cacheable)

  Called by the cache to signal that a page was replaced in order to store the Cacheable object passed.

  Parameters:
    `cacheable` -

### getThrashing

    public int getThrashing()

  Return the current amount of trashing.

  Returns:
    current amount of trashing

### resizeNeeded

    public boolean resizeNeeded()

  Returns true if a cache resize would increase the cache efficiency.

  Returns:
    True if a cache resize would increase the cache efficiency

### reset

    public void reset()

### stats

    public void stats()

Copyright (C) Wolfgang Meier. All rights reserved.