-- File DBCache.Mesa 
-- Last edited by
--   MBrown on November 24, 1982 1:04 pm


  DIRECTORY
    DBCommon USING [DBPage];

DBCache: DEFINITIONS = BEGIN
 

  --  Types

  CacheHandle: TYPE = REF CacheRecord;
  CacheRecord: PRIVATE TYPE = RECORD [
    dbPage: DBCommon.DBPage,
      -- database page number
    pagePtr: LONG POINTER,
      -- location of the cache page in memory
    lockCount: [0..7777B] ← 0,
      -- incremented by read page, write page; decremented by unlock page.  If >0, page
      --will not move in core or leave cache.
    occupied: BOOL ← FALSE,
      -- true if this page contains valid data (is contained in ht).
    written: BOOL ← FALSE,
      -- true if this page has been written, needs to be stored back to file system.
    readonly: BOOL ← FALSE,
      -- true iff this page cannot be written (according to the file system).
    pred: CacheHandle,
    succ: CacheHandle,
      -- Doubly-linked list of cache handles, used to maintain LRU information.
    hashChain: CacheHandle
      -- Singly-linked list of cache handles, used to resolve hash table collisions.
    ];
    -- Represents an association between a database page and a core page.  This
    --association is guaranteed while the page is "locked" (see ReadPage below), but may
    --be broken at other times.  Access to a page is more efficient if the CacheHandle
    --is known in addition to the DBPage address, since hashing is avoided.

END.--DBCache


CHANGE LOG

Created by MBrown on January 4, 1980  2:21 PM
--  Adopted in meeting of 4 January; DBCacheDefs and DBFileDefs replace the former
--DBCacheDefs.

Changed by Suzuki on January 14, 1980  2:29 PM
-- Suffixes Defs are deleted

Changed by Suzuki on January 16, 1980  8:18 AM
-- EnumBRLockProc, RelRLockProc, and ObtainDBPage are added.

Changed by Suzuki on January 17, 1980  1:12 PM
-- WriteoutCache returns TRUE if write can succeed else returns FALSE.

Changed by Suzuki on February 8, 1980  4:28 PM
-- added NewPage and WriteLockedPage.

Changed by MBrown on February 21, 1980  2:32 PM
-- Made WriteLockedPage return no result.  Added comment to NewPage that the contents of
--the page are unpredictable.

Changed by MBrown on February 21, 1980  10:36 PM
-- Added LockCountOfPage.

Changed by Suzuki on April 16, 1980  4:00 PM
-- Added LockCount and ObtainCoreLoc. Deleted LockCountOfPage.

Changed by MBrown on April 20, 1980  4:58 PM
-- Changed the pHint parm of LockCount and ObtainCoreLoc to pValidHint,
--to emphasize that they must be valid for these procs to work.

Changed by MBrown on August 23, 1980  6:20 PM
-- Added CheckState to the interface.

Changed by MBrown on September 3, 1980  10:03 PM
-- CacheHandle is now an opaque type.  Eliminated dependency on ServerPineDefs by making
--lfh be an untyped pointer for now.

Changed by MBrown on September 12, 1980  11:15 AM
-- Added Finalize.

Changed by MBrown on September 18, 1980  3:11 PM
-- Made CacheHandle a LONG POINTER.

Changed by MBrown on February 27, 1981  11:19 AM
-- Flushed all of the stuff relating to broken read locks.

Changed by MBrown on August 6, 1982 2:43 pm
-- CacheHandle is a REF.

Changed by MBrown on November 24, 1982 1:04 pm
-- CacheRecord is concrete here; all procs are eliminated, as we are merging the cache and
--segment implementations.