This package implements a generic disk-based cache.
Example:
(defparameter *web-cache* (make-instance 'cache :directory-path "CACHE:WEB;"
:value-file-type "HTML"
:producer (function get-url)))
(cache-get *web-cache* "http://www.informatimago.com/")
--> "<!DOCTYPE html PUBLIC …" ; :FETCHED
(cache-get *web-cache* "http://www.informatimago.com/")
--> "<!DOCTYPE html PUBLIC …" ; :IN-CORE
License:
AGPL3
Copyright Pascal J. Bourguignon 2005 - 2015
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program.
If not, see <http://www.gnu.org/licenses/>
|
cache |
class |
A generic disk-based cache.
Class precedence list: CACHE STANDARD-OBJECT T
Class init args: DIRECTORY-PATH VALUE-FILE-TYPE PRODUCER
|
(cache-directory-path cache) |
generic-function |
Path to the directory where the cache data is stored.
|
(cache-expiration cache key) |
generic-function |
RETURN: NIL or the universal-time of expiration of the CACHE.
|
(cache-expire cache key &key keep-file) |
generic-function |
DO: Expire the entry KEY from the CACHE. KEEP-FILE: When true, the file is not deleted from the cache.
|
(cache-expire-all cache &key keep-files) |
generic-function |
DO: Expire all the entries from the CACHE. KEEP-FILE: When true, the files are not deleted from the cache.
|
(cache-get cache key) |
generic-function |
RETURN: the value stored in the CACHE for the KEY;
:FETCHED --> the value was obtained by the CACHE-PRODUCER.
:IN-CORE --> the value was in memory
:ON-DISK --> the value was on disk (in the disk cache).
|
(cache-index-file-path cache) |
generic-function |
RETURN: The path to the cache index file.
|
(cache-producer cache) |
generic-function |
RETURN: The cache producer of the cache.
|
(cache-value-file-type cache) |
generic-function |
RETURN: The type used for value files in the cache directory.
|
entry |
structure |
A cache index entry, mapping a key with the date the resource was fetched and the file-name of the files where the resource and the parsed html are stored, and references to these data when they are loaded in core.
|
(entry-expire-date entry) |
function |
RETURN: The universal-time when the entry expires.
|
(entry-fetch-date entry) |
function |
RETURN: The universal-time when the entry was stored.
|
(entry-file-name entry) |
function |
RETURN: The name of the file where the value is stored.
|
(entry-key entry) |
function |
RETURN: The key of the entry.
|
(entry-value entry) |
function |
PRE: (entry-value-p entry) RETURN: The value of the entry.
|
(entry-value-p entry) |
function |
RETURN: Whether the value of the entry is loaded.
|
(make-cache directory producer &key value-file-type) |
function |
DO: Make a new cache instance. NOTE: Send synchronize
|
(synchronize-cache cache) |
generic-function |
DO: Ensure the cache index in core and on disk are synchronized.