Base interface for cache-like data structures.
interface
|
ICacheBase
|
with
|
<TId>
|
||
base of
|
ICache
|
||||
SimpleCache
|
The following terms are used by this interface:
{ID
=>
index}
is
stored
and
maintained.
The
current
mappings
can
be
queried
by
using
the
GetId
and
GetIndex
method.
The capacity of this cache.
property
|
Capacity
{
get
}
|
||
type
|
int32
|
||
value
|
|
The maximum number of entries this cache can hold. |
The page ID value that represents non-existent mappings.
property
|
InvalidId
{
get
}
|
||
type
|
TId
|
||
value
|
The invalid page ID value. |
Returns the index of the oldest cache page.
property
|
Oldest
{
get
}
|
||
type
|
int32
|
||
value
|
|
Index
of
the
least-recently
used
cache
page
or
-1
if
all
pages
are
unused.
|
Evicts all pages from the cache.
method
|
EvictAll
()
|
Evicts the given page from the cache.
method
|
EvictId
(TId pageId)
|
||
params
|
pageId
|
The cache page ID. |
Remarks:
Requesting the given page later will cause a cache miss.
Evicts the given page from the cache.
method
|
EvictIndex
(int32 pageIndex)
|
||
params
|
pageIndex
|
[0..Capacity-1]
|
The cache page index. |
Remarks:
Requesting the given page later will cause a cache miss.
Fetches a page from the cache, loading it if necessary.
method
|
Fetch
(TId pageId)
|
||
type
|
int32
|
||
params
|
pageId
|
The page ID. | |
returns
|
|
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. |
Remarks:
The state of the cache is not modified by this method.
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
|
|
The
cache
page
index
or
-1 . |
Remarks:
The
state
of
the
cache
is
not
modified
by
this
method
if
hitPage
is
false
.
The given cache page has been used.
method
|
Use
(int32 pageIndex)
|
||
params
|
pageIndex
|
[0..Capacity-1]
|
The page index. |
Remarks:
Use this method to avoid specific pages to get evicted from the cache too soon.