## org.h2.util
Class CacheObject

    java.lang.Object
      org.h2.util.CacheObject

Direct Known Subclasses:
  CacheHead, Record

    public abstract class CacheObject

extends java.lang.Object

The base object for all cached objects.

Field Summary
`protected int` `blockCount` The number of blocks occupied by this object.
`int` `cacheQueue` The cache queue identifier.
`CacheObject` `chained` The next element in the hash chain.
`CacheObject` `next` The next element in the LRU linked list.
`CacheObject` `previous` The previous element in the LRU linked list.

Constructor Summary
`CacheObject()`

Method Summary
`abstract boolean` `canRemove()` Check if the object can be removed from the cache.
`int` `getBlockCount()`
`int` `getMemorySize()` Get the estimated memory size.
`int` `getPos()`
`boolean` `isChanged()` Check if this cache object has been changed and thus needs to be written back to the storage.
`boolean` `isPinned()` Check if this cache object can be removed from the cache.
`void` `setBlockCount(int size)`
`void` `setChanged(boolean b)`
`void` `setPos(int pos)`
`static void` `sort(ObjectArray<CacheObject> recordList)` Order the given list of cache objects by position.

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

Field Detail

### previous

    public CacheObject previous

  The previous element in the LRU linked list. If the previous element is the head, then this element is the most recently used object.

### next

    public CacheObject next

  The next element in the LRU linked list. If the next element is the head, then this element is the least recently used object.

### chained

    public CacheObject chained

  The next element in the hash chain.

### cacheQueue

    public int cacheQueue

  The cache queue identifier. This field is only used for the 2Q cache algorithm.

### blockCount

    protected int blockCount

  The number of blocks occupied by this object.

Constructor Detail

### CacheObject

    public CacheObject()

Method Detail

### canRemove

    public abstract boolean canRemove()

  Check if the object can be removed from the cache. For example pinned objects can not be removed.

  Returns:
    true if it can be removed

### sort

    public static void sort(ObjectArray<CacheObject> recordList)

  Order the given list of cache objects by position.

  Parameters:
    `recordList` - the list of cache objects

### setBlockCount

    public void setBlockCount(int size)

### getBlockCount

    public int getBlockCount()

### setPos

    public void setPos(int pos)

### getPos

    public int getPos()

### isChanged

    public boolean isChanged()

  Check if this cache object has been changed and thus needs to be written back to the storage.

  Returns:
    if it has been changed

### setChanged

    public void setChanged(boolean b)

### isPinned

    public boolean isPinned()

  Check if this cache object can be removed from the cache.

  Returns:
    if it can be removed

### getMemorySize

    public int getMemorySize()

  Get the estimated memory size.

  Returns:
    number of double words (4 bytes)