home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / db02_src.zip / cache.h < prev    next >
C/C++ Source or Header  |  1993-11-05  |  2KB  |  94 lines

  1. /*************************************************************************
  2.  * Source Id :
  3.  *
  4.  * $Id: cache.h,v 1.6 1993/06/23 05:21:22 kevinl Exp $
  5.  *-------------------------------------------------------------------------
  6.  * Project Notes :
  7.  *
  8.  *  Diamond Base
  9.  *  ============
  10.  *      A solid database implementation, spurred on by the continuing
  11.  *  Metal (Lead) Base saga.
  12.  *
  13.  *  Project Team :
  14.  *        A. Davison
  15.  *        K. Lentin
  16.  *        D. Platt
  17.  *
  18.  *    Project Commenced : 05-02-1993
  19.  *
  20.  *-------------------------------------------------------------------------
  21.  *  Module Notes :
  22.  *
  23.  *  Record caching for dbobj
  24.  *
  25.  *
  26.  *  Original Author : Kev
  27.  *
  28.  *-------------------------------------------------------------------------
  29.  * Revision History:
  30.  *
  31.  * $Log: cache.h,v $
  32.  * Revision 1.6  1993/06/23  05:21:22  kevinl
  33.  * Mallocs are now in angular brackets
  34.  *
  35.  * Revision 1.5  1993/05/11  14:44:50  kevinl
  36.  * Added version number output
  37.  *
  38.  * Revision 1.4  1993/05/03  01:33:55  kevinl
  39.  * whereCache not inline
  40.  *
  41.  * Revision 1.3  1993/04/25  10:11:47  kevinl
  42.  * Added freeCache to allow destructing/reconstructing properly (in case)
  43.  * Comments!
  44.  *
  45.  * Revision 1.2  1993/04/09  13:00:29  kevinl
  46.  * Stats can be called from diaRel now.
  47.  *
  48.  * Revision 1.1  1993/04/05  00:00:08  kevinl
  49.  * Initial revision
  50.  *
  51.  **************************************************************************/
  52.  
  53. #ifndef __CACHE_H
  54. #define __CACHE_H
  55.  
  56. #include <defs.h>
  57.  
  58. const DEF_CACHE_SIZE = 10;
  59.  
  60. // A block of the cache has an id number and block of data
  61.  
  62. struct cacheBlock {
  63.     char*    block;
  64.     long    id;
  65. };
  66.  
  67. // The cache class itself
  68.  
  69. class cache {
  70.     cacheBlock*    data;        // The array of blocks
  71.     long        cacheSize;    // The number of blocks to cache
  72.     long        blockSize;    // How big each block is
  73.     long        curSize;    // How many we have currently
  74.     long        attempts;    // The stats
  75.     long        hits;
  76.     long        writes;
  77.     long        dispose;
  78.  
  79. public:
  80.         cache(long bSize, long cSize = DEF_CACHE_SIZE);
  81.         cache(void);
  82.         ~cache();
  83.     char*    verStr(void);
  84.     void    createCache(long bSize, long cSize = DEF_CACHE_SIZE);
  85.     void    freeCache(void);
  86.     bool    inCache(long id);
  87.     long    whereCache(long id);
  88.     bool    getCache(char* where, long id);
  89.     void    putCache(char* where, long id);
  90.     void    stats(void);
  91. };
  92.  
  93. #endif
  94.