DataCache

Description

abstract class Tinman.Core.Caching.DataCache

Derived from

Disposable abstract
ICacheCallback<int64>
IBeginEndSync

Extended by

FileCache sealed
ObjectDataCache abstract

Base class for objects that implement a thread-safe and page based cache for a number of independent source data objects.

Public / Methods

Access


[BeginEnd]
public method Access → (3)

sourceId in : int32

The source ID of the source data object that contains the page to access.

sourceIndex in : int64

The source data object page index (54-bit).

loadFlags opt : PageLoadFlags = PageLoadFlags.Load

The flags that determine how to load the cache page. When set to PageLoadFlags.Manual, the IDataCacheObject.CacheReadPage method will not be called. The calling code must load the cache page in this case.

returns → int32

The cache page index.

Accesses a cache page.

The returned cache page can be accessed safely by the calling thread until it calls one of the following methods:

IOException

If an I/O error has occurred in IDataCacheObject.CacheReadPage or IDataCacheObject.CacheWritePage for the given source data object.

Flush


[BeginEnd]
public method Flush → (1)

sourceId in : int32

The ID of the source data object.

Flushes all dirty cache pages of the given source object.

IOException

If an I/O error has occurred in IDataCacheObject.CacheReadPage or IDataCacheObject.CacheWritePage for the given source data object.

Is​Dirty


[BeginEnd]
public method IsDirty → (1)

cacheIndex in : int32

The cache page index.

returns → bool

true if the page is dirty, false if not.

Returns if the given page is dirty.

Lock​Page


[BeginEnd]
public method LockPage → (1)

cacheIndex in : int32

The cache page index.

Locks a cache page.

Locked pages cannot be evicted from the cache. For each call to LockPage, the UnlockPage method must be called once to unlock the page.

Make​Page​Id


[Pure]
public static method MakePageId → (2)

sourceId in : int32

The 10-bit source ID value.

sourceIndex in : int64

The 54-bit source index value.

returns → int64

The 64-bit page ID value.

Makes a 64-bit page ID value.

Make​Source​Id


[Pure]
public static method MakeSourceId → (1)

pageId in : int64

The 64-bit page ID value.

returns → int32

The 10-bit source ID value.

Makes a 10-bit source ID value.

Make​Source​Index


[Pure]
public static method MakeSourceIndex → (1)

pageId in : int64

The 64-bit page ID value.

returns → int64

The 54-bit source index value.

Makes a 54-bit source index value.

Release

2 overloads


[BeginEnd]
public method Release1 → (2)

sourceId in : int32

The source ID.

sourceIndex in : int64

The source page to release.

Releases a page.

If the given page is not present in the cache, the method returns silently.

IOException

If an I/O error has occurred in IDataCacheObject.CacheReadPage or IDataCacheObject.CacheWritePage for the given source data object.


[BeginEnd]
public method Release2 → (3)

sourceId in : int32

The source ID.

sourceIndex in : int64

Index of first source file page to release (54-bit).

count in : int64

Number of source file pages to release.

Releases a range of source file pages.

If the given page is not present in the cache, the method returns silently.

IOException

If an I/O error has occurred in IDataCacheObject.CacheReadPage or IDataCacheObject.CacheWritePage for the given source data object.

Set​Dirty


[BeginEnd]
public method SetDirty → (2)

cacheIndex in : int32

The cache page index.

dirty opt : bool = true

Set dirty flag?

Marks a cache page as dirty or not dirty.

Source​Id​Allocate


[BeginEnd]
public method SourceIdAllocate → (1)

sourceData in : IDataCacheObject

The source data object.

returns → int32

The source ID.

Allocates a source ID in this cache for the given source data object.

IOException

If all source ID values are already in use.

Source​Id​Release


[BeginEnd]
public method SourceIdRelease → (2)

sourceId in : int32

The source ID.

discardDirty opt : bool = false

Discard all dirty pages?

returns → bool

true if at least one more source is associated with this cache, false if not.

Releases a source ID.

IOException

If an I/O error has occurred in IDataCacheObject.CacheReadPage or IDataCacheObject.CacheWritePage for the given source data object.

Source​Index


[BeginEnd]
public method SourceIndex → (2)

sourceId in : int32

The source ID.

cacheIndex in : int32

The cache page index.

returns → int64

The source index or -1.

Returns the source index of the given cache slot.

Unlock​Page


[BeginEnd]
public method UnlockPage → (1)

cacheIndex in : int32

The cache page index.

Unlocks a cache page.

Locked pages cannot be evicted from the cache. For each call to LockPage, the UnlockPage method must be called once to unlock the page.

Weight


[BeginEnd]
public method Weight → (2)

pageIndex in : int32

The cache page index.

weight in : int32

The new page weight.

Updates the weight of the given cache page.

Public / Attributes

Has​Source​Files


public attribute HasSourceFiles → (get)

value : bool

true if at least one source data file is present, false if not.

Returns if this data cache currently has one or more source data files attached to it.

Max​Weight​Sum


public attribute MaxWeightSum → (get,set)

value : int64

[>=0]
The maximum weight sum. If 0 the maximum limit is disabled.

The maximum page weight sum.

Protected / Constructors

Data​Cache


protected constructor DataCache → (1)

pageCount in : int32

[>0]
The number of cache pages.

Creates a new instance of DataCache.

Protected / Methods

Clear​Page


[EmptyBody]
protected virtual method ClearPage → (1)

pageIndex in : int32

Page index of cache slot to clear.

Clears the given cache slot.

The GetWeight method must return 0 for cleared cache slots.

Get​Weight


protected virtual method GetWeight → (1)

pageIndex in : int32

Page index of cache slot.

returns → int64

The page weight.

Returns the weight of the given cache slot.

Protected / Attributes

page​Count


protected readonly attribute pageCount → (int32)

The number of cache pages.

Logging

Logger


public static readonly attribute Logger → (ILogger)

The logger object of this class.