TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

class SimpleCache in Tinman.Core.Caching

A cache that uses a simple LRU (least-recently-used) replacement scheme.

sealed class SimpleCache implements ICacheBase<int64>

Public / Attributes

Capacity

The capacity of this cache.

public property Capacity { get }
type int32
value [>0] The maximum number of entries this cache can hold.
implements ICacheBase.Capacity

InvalidId

The page ID value that represents non-existent mappings.

public property InvalidId { get }
type int64
value The invalid page ID value.
implements ICacheBase.InvalidId

Oldest

Returns the index of the oldest cache page.

public property Oldest { get }
type int32
value [-1..Capacity-1] Index of the least-recently used cache page or -1 if all pages are unused.
implements ICacheBase.Oldest

Public / Constructors

SimpleCache

Creates a new instance of SimpleCache.

public constructor SimpleCache (int32 capacity, int64 invalidId)
params capacity [>0] The cache capacity.
  invalidId The page ID value that represents an invalid page ID. Unused cached slots will be set to this value.

Public / Methods

EvictAll

Evicts all pages from the cache.

public method EvictAll ()
implements ICacheBase.EvictAll

EvictId

Evicts the given page from the cache.

public method EvictId (int64 pageId)
params pageId The cache page ID.
implements ICacheBase.EvictId

Remarks:

Requesting the given page later will cause a cache miss.

EvictIndex

Evicts the given page from the cache.

public method EvictIndex (int32 pageIndex)
params pageIndex [0..Capacity-1] The cache page index.
implements ICacheBase.EvictIndex

Remarks:

Requesting the given page later will cause a cache miss.

Fetch

Fetches a page from the cache, loading it if necessary.

public method Fetch (int64 pageId)
type int32
params pageId The page ID.
returns
  • [>=0]:
    The page is present in the cache, the return value is its index.
  • [&lt;=-1]:
    The page is not present in the cache and shall be loaded into the cache using the page index given by -1-value, where value is the value that is returned by this method.
implements ICacheBase.Fetch

GetId

Returns the page ID of the given page.

public method GetId (int32 pageIndex)
type int64
params pageIndex [0..Capacity-1] The page index.
returns The page ID.
implements ICacheBase.GetId

Remarks:

The state of the cache is not modified by this method.

GetIndex

Returns the cache page index of the given page.

public method GetIndex (int64 pageId, bool hitPage = false)
type int32
params pageId The page ID.
  hitPage Update state of the cache by hitting the page if it exists?
returns [>=-1] The cache page index or -1.
implements ICacheBase.GetIndex

Remarks:

The state of the cache is not modified by this method if hitPage is false.

Use

The given cache page has been used.

public method Use (int32 pageIndex)
params pageIndex [0..Capacity-1] The page index.
implements ICacheBase.Use

Remarks:

Use this method to avoid specific pages to get evicted from the cache too soon.