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

interface ICache in Tinman.Core.Caching

Base interface for cache-like data structures with extended functionality.

interface ICache with <TId>  
  extends ICacheBase<TId>
  base of LruCache

Remarks

This interface is based on ICacheBase, and provides additional features:

Attributes

Capacity

The capacity of this cache.

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

InvalidId

The page ID value that represents non-existent mappings.

property InvalidId { get }
type TId
value The invalid page ID value.
inherited ICacheBase.InvalidId

Oldest

Returns the index of the oldest cache page.

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

Methods

EvictAll

Evicts all pages from the cache.

method EvictAll ()
inherited ICacheBase.EvictAll

EvictId

Evicts the given page from the cache.

method EvictId (TId pageId)
params pageId The cache page ID.
inherited ICacheBase.EvictId

Remarks:

Requesting the given page later will cause a cache miss.

EvictIndex

Evicts the given page from the cache.

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

Remarks:

Requesting the given page later will cause a cache miss.

Fetch

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

method Fetch (TId 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.
inherited ICacheBase.Fetch

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

method Fetch (TId pageId, PageLoadFlags loadFlags, bool keepLocked)
type int32
params pageId The page ID.
  loadFlags The flags that determine how to load the cache page. When set to Manual, cache page loading will not be performed. The calling code must load the cache page in this case.
  keepLocked Keep the cache page in locked state after fetching it (see LockPage)?
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-return.

Remarks:

When this method returns, all necessary calls to CachePageChoose and CachePageData will have been done.

GetId

Returns the page ID of the given page.

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

Remarks:

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

GetIndex

Returns the cache page index of the given page.

method GetIndex (TId 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.
inherited ICacheBase.GetIndex

Remarks:

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

IsPageLocked

Is the given cache page locked?

method IsPageLocked (int32 pageIndex)
type bool
params pageIndex [0..Capacity-1] Index of page to unlock.
returns true if the cache page is locked, false if not.

See also:

LockPage
UnlockPage

IsPartial

Has the given page been partially loaded?

method IsPartial (int32 pageIndex)
type bool
params pageIndex [0..Capacity-1] The page index.
returns true if the given page has been loaded partially, false if the page is either fully loaded or non-existent.

See also:

PageLoadFlags.Partial

LockPage

Locks a cache page so that it will not be evicted from the cache by future calls.

method LockPage (int32 pageIndex)
params pageIndex [0..Capacity-1] Index of page to lock.

See also:

UnlockPage

UnlockPage

Unlocks a previously locked cache page.

method UnlockPage (int32 pageIndex)
params pageIndex [0..Capacity-1] Index of page to unlock.

See also:

LockPage

Use

The given cache page has been used.

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

Remarks:

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