Skip to content
Snippets Groups Projects
Commit 2ce3362a authored by David Kågedal's avatar David Kågedal
Browse files

Ny lågnivåimplementering, men den är utkommenterad tills vidare.

parent bcecf244
No related branches found
No related tags found
No related merge requests found
...@@ -406,6 +406,72 @@ CACHE is the name of the variable that points to the cache." ...@@ -406,6 +406,72 @@ CACHE is the name of the variable that points to the cache."
(set cache nil) (set cache nil)
(setq lyskom-caches (delete cache lyskom-caches))) (setq lyskom-caches (delete cache lyskom-caches)))
;; (defsubst cache-hash (key cache)
;; "Return a hash value for use in the cache."
;; (mod key (length (aref cache 2))))
;;
;; (defun cache-create (cache &optional size)
;; (set cache (vector 'CACHE-HASH (or size 1000)
;; (make-vector (or size 1000) nil)))
;; (if (not (memq cache lyskom-caches))
;; (setq lyskom-caches (cons cache lyskom-caches)))
;; (symbol-value cache))
;;
;; (defun cache-rehash (cache-symbol)
;; (let* ((cache (symbol-value cache-symbol))
;; (newsize (/ (aref cache 1) 5))
;; (oldsize (length (aref cache 2)))
;; (i 0))
;; (cache-create cache-symbol newsize)
;; (while (< i oldsize)
;; (let ((entries (aref cache i)))
;; (while entries
;; (cache-add cache-symbol (car (car entries)) (cdr (car entries)))
;; (setq entries (cdr entries))))
;; (setq i (1+ i)))
;; (symbol-value cache-symbol)))
;;
;; (defun cache-assoc (key cache)
;; "Get data for item with key KEY from CACHE.
;; CACHE is an assoc-list in this implementation."
;; (if cache
;; (cdr-safe (assq key (aref (aref cache 2)
;; (cache-hash key cache))))))
;;
;;
;;
;; (defun cache-add (key data cache-symbol)
;; "Add DATA to CACHE under the key KEY.
;; Args: KEY DATA CACHE.
;; CACHE is a (the only one) quoted variable pointing to the cache (an alist).
;; The variable might be changed."
;; (let ((cache (symbol-value cache-symbol)))
;; (if (null cache)
;; (setq cache (cache-create cache-symbol))
;; (if (> (aset cache 1 (1+ (aref cache 1)))
;; (* (length (aref cache 2)) 20))
;; (setq cache (cache-rehash cache-symbol))))
;; (let ((hash (cache-hash key cache)))
;; (aset (aref cache 2) hash
;; (cons (cons key data) (aref (aref cache 2) hash))))))
;;
;; (defun cache-del (key cache-symbol)
;; "Delete item with key KEY from CACHE.
;; CACHE is the name of the variable that points to the cache."
;; (let ((cache (symbol-value cache-symbol)))
;; (if cache
;; (let* ((hash (cache-hash key cache))
;; (entries (aref (aref cache 2) hash))
;; (ass (assq key entries)))
;; (if ass
;; (progn (aset cache 1 (1- (aref cache 1)))
;; (aset (aref cache 2) hash
;; (delq ass entries))))))))
;;
;; (defun cache-clear (cache)
;; (set cache nil)
;; (setq lyskom-caches (delete cache lyskom-caches)))
(defun clear-all-caches () (defun clear-all-caches ()
(mapcar (function (lambda (cache) (set cache nil))) (mapcar (function (lambda (cache) (set cache nil)))
lyskom-caches) lyskom-caches)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment