From aa86b62d7907f75d956d9bcf988c986c0cec231c Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Sat, 4 Dec 2010 20:08:16 +0100 Subject: simpler caching algorithm * tekuti/cache.scm: Simpler LRU algorithm for the cache. Conses more, but throws away the cache less. --- tekuti/cache.scm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tekuti/cache.scm b/tekuti/cache.scm index abb1841..73228e0 100644 --- a/tekuti/cache.scm +++ b/tekuti/cache.scm @@ -41,7 +41,8 @@ (apply values (assoc-ref (cdr cache) (request-uri request)))) (define (cache-set cache master request . args) - (append (if (and cache (< (length cache) 20)) - cache - (list master)) - (acons (request-uri request) args '()))) + (cons* master + (cons (request-uri request) args) + (if (and cache (equal? (car cache) master)) + (list-head (cdr cache) 9) + '()))) -- cgit v1.2.3-54-g00ecf