XEROX CASH-FILE 2 4 1 CASH-FILE 1 4 By: Doug Cutting (cutting.pa@xerox.com) Uses: HASH-FILE This document last edited on July 28, 1987. INTRODUCTION CASH-FILE is a front end to hash files which uses a hash table to cache accesses to the hash file. All of the code for CASH-FILE is in a package called CASH-FILE. Througout this document LISP symbols will be printed as though in a package which uses the packages CASH-FILE, HASH-FILE and LISP. FUNCTIONAL INTERFACE The functional interface is designed to closely resemble that of HASH-FILE, which was in turn designed to resemble the Common LISP hash table facility. (make-cash-file file-name size cache-size) [Function] Creates and returns an empty cash file in file-name. Size is passed as the size argument to make-hash-file, while cache-size is passed as the size argument to make-hash-table and determines the maximum number of entries which will ever be cached. (get-cash-file key cash-file &optional default) [Function] Just like get-hash-file and gethash. Retrives the value stored under key in cash-file or default if there is none. Also returns a second value which is true iff a value was found for key. There is also a setf method defined for get-cash-file . (open-cash-file file-name cache-size &key direction) [Function] Open the existing hash file in file-name in direction (:input or :io) . Cache-size is passed as the size argument to make-hash-table and determines the maximum number of entries which will ever be cached. (rem-cash-file key cash-file) [Function] Like rem-hash-file and remhash. Deletes key from the hash file and the cache. Returns true iff there was a value stored under key. (cash-file-p object) [Function] Returns true iff object is a cash file. (cash-file-p object)ÿÿ ïrÿ(typep object 'cash-file) (cash-file-hash-file cash-file) [Function] Returns the hash file object which cash-file is a front end to. There are no cash file specific equivalents for close-hash-file, map-hash-file and hash-file-count. For these use the hash file functions on the cash-file-hash-file . IMPLEMENTATION NOTES A queue is maintained to enable cache deletion when the cache is full. This queue is implemented as a list. Each time a key is accessed it is moved to the head of the queue. The last element of the queue is deleted when a new key is accessed and the queue is full. Thus the cache time is not constant but grows linearly with the size of the cache. For this reason huge caches are not recommended. (LIST ((PAGE NIL (PAPERSIZE LETTER STARTINGPAGE# 36) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO NIL) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL))) (PAGE NIL (PAPERSIZE NIL . LETTER) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO NIL) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL))) (PAGE NIL (PAPERSIZE NIL . LETTER) (0 0 612 792) ((FOLIO NIL (PARALOOKS (QUAD CENTERED) CHARLOOKS (SUPERSCRIPT 0 INVISIBLE OFF SELECTPOINT OFF PROTECTED OFF SIZE 10 FAMILY MODERN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF EXPANSION REGULAR SLOPE REGULAR WEIGHT MEDIUM INVERTED OFF USERINFO NIL STYLE NIL) FORMATINFO NIL) (174 36 288 36) NIL) (HEADING NIL (HEADINGTYPE RUNNINGHEAD) (84 744 528 36) NIL) (TEXT NIL NIL (84 96 456 600) NIL)))))2ÈÈT/ÈÈT(È.È È(È(ŠŠ8(ŠŠ8DÈÈ PAGEHEADING RUNNINGHEADMODERN TERMINAL MODERN MODERN MODERN MODERNMODERN LOGO  HRULE.GETFNMODERN  HRULE.GETFNMODERN  HRULE.GETFNMODERN   HRULE.GETFNMODERN  HRULE.GETFNMODERN ), dĘ *    I   # X #     I  g    # 0 0 † Ç¢zº