org.h2.util

## Class CacheObject

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

All Implemented Interfaces:
  java.lang.Comparable<CacheObject>

Direct Known Subclasses:
  CacheHead, Page

    public abstract class CacheObject
    extends java.lang.Object
    implements java.lang.Comparable<CacheObject>

The base object for all cached objects.

### Field Summary

Fields
`CacheObject` `cacheChained` The next element in the hash chain.
`CacheObject` `cacheNext` The next element in the LRU linked list.
`CacheObject` `cachePrevious` The previous element in the LRU linked list.

### Constructor Summary

Constructors
Constructor and Description
`CacheObject()`

### Method Summary

Methods
`abstract boolean` `canRemove()` Check if the object can be removed from the cache.
`int` `compareTo(CacheObject other)`
`abstract int` `getMemory()` Get the estimated used memory.
`int` `getPos()`
`boolean` `isChanged()` Check if this cache object has been changed and thus needs to be written back to the storage.
`boolean` `isStream()`
`void` `setChanged(boolean b)`
`void` `setPos(int pos)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### cachePrevious

    public CacheObject cachePrevious

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

#### cacheNext

    public CacheObject cacheNext

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

#### cacheChained

    public CacheObject cacheChained

The next element in the hash chain.

### 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

#### getMemory

    public abstract int getMemory()

Get the estimated used memory.

Returns:
  number of words (one word is 4 bytes)

#### 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)

#### compareTo

    public int compareTo(CacheObject other)

Specified by:
  `compareTo` in interface `java.lang.Comparable<CacheObject>`

#### isStream

    public boolean isStream()