Scieneer Common Lisp 1.3.9 online documentation ext:defun-cached (name &key :hash-function :hash-bits :init-form :values) args &parse-body (body decls doc) [Macro] defun-cached (name {key value}*) ({(arg-name test-function)}*) form*
Define a hash cache that associates some number of argument values to a result value. The test-function paired with each arg-name is used to compare the value for that arg in a cache entry with a supplied arg. The test-function must not error when passed nil as its first arg, but need not return any particular value. test-function may be any thing that can be place in car position.
Name is used to define functions these functions:
- <name>-cache-invalidate
- Invalidating all entries.
- <name>-cache-clear
- Reinitialize the cache, invalidating all entries and allowing the arguments and result values to be GC'd.
These other keywords are defined:
- :hash-bits <n>
- The size of the cache as a power of 2.
- :hash-function function
- Some thing that can be placed in car position which will compute a value between 0 and (1- (expt 2 <hash-bits>)).
- :values <n>
- The number of values cached.
- :init-form <name>
- The defvar for creating the cache is enclosed in a form with the specified name. Default progn.