ICacheBase
Description
- Extended by
-
ICache
SimpleCache sealed
Base interface for cache-like data structures.
The following terms are used by this interface:
-
page:
A page is a logical piece of information which is expensive to obtain or access. -
cache:
A cache is a container that can store a number of pages and provides fast access to them. -
capacity:
The capacity of a cache is the maximum number of pages that it can store. -
page id:
The page ID can be used to uniquely refer to a page. -
page index:
The page index is the storage position of the page in the cache container.
A ICacheBase object is responsible for the following tasks:
-
Page loading / unloading:
When a page is requested for the first time, it must be loaded into the cache. If all caches pages are used, the oldest page must be evicted in order to make room for the new page. The load / unload actions are not performed by the cache itself. Pages are requested via Fetch. Page can be evicted by using one of the EvictAll, EvictId and EvictIndex methods. -
Mapping of page IDs to page indices:
For each cached paged, a mapping of the form{ID => index}
is stored and maintained. The current mappings can be queried by using the GetId and GetIndex method.
Client code can use the cache page index values for storing additional data per cache page.
Public / Methods
EvictId
Evicts the given page from the cache.
Requesting the given page later will cause a cache miss.
EvictIndex
Evicts the given page from the cache.
Requesting the given page later will cause a cache miss.
GetId
Returns the page ID of the given page.
The state of the cache is not modified by this method.