Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Berkeley DB Java Edition version 3.3.75
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD

## com.sleepycat.je
Enum CacheMode

    java.lang.Object
      java.lang.Enum<CacheMode>
          com.sleepycat.je.CacheMode

All Implemented Interfaces:
  Serializable, Comparable<CacheMode>

    public enum CacheMode

extends Enum<CacheMode>

Modes that can be specified for control over caching of records in the JE in-memory cache. When a record is stored or retrieved, the cache mode determines how long the record is subsequently retained in the JE in-memory cache, relative to other records in the cache.

When the cache overflows, JE must evict some records from the cache. By default, JE uses a Least Recently Used (LRU) algorithm for determining which records to evict. With the LRU algorithm, JE makes a best effort to evict the "coldest" (least recently used or accessed) records and to retain the "hottest" records in the cache for as long as possible.

A non-default cache mode may be explicitly specified to override the default behavior of the LRU algorithm. See `KEEP_HOT` and `UNCHANGED` for more information. When no cache mode is explicitly specified, the default cache mode is `DEFAULT`. The default mode causes the normal LRU algorithm to be used.

Note that JE makes a best effort to implement an approximation of an LRU algorithm, and the very coldest record is not always evicted from the cache first. In addition, hotness and coldness are applied to the portion of the in-memory BTree that is accessed to perform the operation, not just to the record itself.

The cache mode for cursor operations can be specified by calling `Cursor.setCacheMode` after opening a `Cursor`. The cache mode applies to all operations subsequently performed with that cursor until the cursor is closed or its cache mode is changed. The cache mode for `Database` methods may not be specified and the default cache mode is always used. To override the default cache mode, you must open a Cursor.

Enum Constant Summary
`DEFAULT` The record's hotness is changed to "most recently used" by the operation where this cache mode is specified.
`KEEP_HOT` The record is assigned "maximum hotness" by the operation where this cache mode is specified.
`UNCHANGED` The record's hotness or coldness is unchanged by the operation where this cache mode is specified.

Method Summary
`static CacheMode` | `valueOf(String name)` Returns the enum constant of this type with the specified name.
`static CacheMode[]` | `values()` Returns an array containing the constants of this enum type, in the order they are declared.

Methods inherited from class java.lang.Enum
`clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

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

Enum Constant Detail

### DEFAULT

    public static final CacheMode DEFAULT

  The record's hotness is changed to "most recently used" by the operation where this cache mode is specified.

  The record will be colder then other records accessed with a `KEEP_HOT` cache mode. Otherwise, the record will be hotter than other records accessed before it and colder then other records accessed after it.

  This cache mode is used when the application does not need explicit control over the cache and a standard LRU implementation is sufficient.

### UNCHANGED

    public static final CacheMode UNCHANGED

  The record's hotness or coldness is unchanged by the operation where this cache mode is specified.

  If the record was present in the cache prior to this operation, then its pre-existing hotness or coldness will not be changed. If the record was added to the cache by this operation, it will have "maximum coldness" and will therefore be colder than other records.

  This cache mode is normally used when the application does not intend to access this record again soon.

### KEEP_HOT

    public static final CacheMode KEEP_HOT

  The record is assigned "maximum hotness" by the operation where this cache mode is specified.

  The record will have the same hotness as other records accessed with this cache mode. Its relative hotness will not be reduced over time as other records are accessed. It can only become colder over time if it is subsequently accessed with the `DEFAULT` cache mode.

  This cache mode is normally used when the application intends to access this record again soon.

Method Detail

### values

    public static CacheMode[] values()

  Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

      for (CacheMode c : CacheMode.values())
          System.out.println(c);

  Returns:
    an array containing the constants of this enum type, in the order they are declared

### valueOf

    public static CacheMode valueOf(String name)

  Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

  Parameters:
    `name` - the name of the enum constant to be returned.
  Returns:
    the enum constant with the specified name
  Throws:
    `IllegalArgumentException` - if this enum type has no constant with the specified name
    `NullPointerException` - if the argument is null

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Berkeley DB Java Edition version 3.3.75
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD

Copyright (c) 2004,2008 Oracle. All rights reserved.