CacheBase

Description

abstract class Tinman.Core.Caching.CacheBase<TId>

Derived from

ICacheBase<TId>

Extended by

LruCache sealed
SimpleCache sealed

Abstract base class for ICacheBase implementations.

Protected / Constructors

Cache​Base


protected constructor CacheBase → (2)

capacity in : int32

[>0]
The cache capacity, see ICacheBase.Capacity.

invalidId in : TId

The value for ICacheBase.InvalidId.

Creates a new instance of CacheBase.

Protected / Methods

Hash​Get


protected method HashGet → (1)

pageId in : TId

The page ID.

returns → int32

The page index or -1.

Retrieves the page index for the given page ID from the hashtable.

Hash​Put


protected method HashPut → (2)

pageId in : TId

The page ID.

pageIndex in : int32

The page index.

Inserts the given mapping from page ID to page index into the hashtable.

If the mapping already exists, the method silently returns.

The indexToId array is updated by this method.

Hash​Remove


protected method HashRemove → (1)

pageId in : TId

The page ID.

returns → int32

The former page index or -1 if there was no mapping for the page.

Removes the ID to index mapping of the given page from the hashtable.

The indexToId array is not updated by this method.

Id​Equals


[Pure]
protected abstract method IdEquals → (2)

in : TId

First key value.

in : TId

Second key value.

returns → bool

true if in and in are equal,
false if they are not.

Checks if the given keys are equal.

Id​Hash


[Pure]
protected abstract method IdHash → (1)

key in : TId

The key value.

returns → int32

The hash value.

Computes a hash value for the given key.

Page​Choose


[EmptyBody]
protected virtual method PageChoose → (1)

pageIndex in : int32

The page index.

returns → bool

true to return the given page from ICacheBase.Oldest,
false to check the next page.

Checks if the given page shall be chosen as the oldest one.

Page​Evict


[EmptyBody]
protected virtual method PageEvict → (2)

pageIndex in : int32

The page index.

pageId in : TId

The page ID.

Evicts the given page.

Page​Unuse


protected method PageUnuse → (1)

pageIndex in : int32

The cache page index.

Marks the given cache page as least-recently-used.

Page​Use


protected method PageUse → (1)

pageIndex in : int32

The cache page index.

Marks the given cache page as most-recently-used.

Protected / Attributes

capacity


protected readonly attribute capacity → (int32)

The cache capacity.

hash​Buckets


protected readonly attribute hashBuckets → (int32 [ ])

The hashtable that maps page ID values to page index values.

hash​Mask


protected readonly attribute hashMask → (int32)

Bitmask for computing modulo by bucket count.

hash​Next


protected readonly attribute hashNext → (int32 [ ])

Mapping from value node index to index of the next value node in hash bucket.

index​To​Id


protected readonly attribute indexToId → (TId [ ])

Mapping from cache page index to cache page ID.

invalid​Id


protected readonly attribute invalidId → (TId)

Special ID value that represent an invalid resp. empty entry.

lru​Head


protected attribute lruHead → (int32)

Index of the cache page that represents the head of the LRU list.

lru​Next


protected readonly attribute lruNext → (int32 [ ])

>= 0 : next pointers of the LRU list for cache pages,
< 0 : not in LRU list, may be interpreted freely by subclass.

lru​Prev


protected readonly attribute lruPrev → (int32 [ ])

>= 0 : previous pointers of the LRU list for cache pages,
< 0 : not in LRU list, may be interpreted freely by subclass.