summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorGravatar Andy Wingo2010-12-04 20:08:16 +0100
committerGravatar Andy Wingo2010-12-04 20:08:16 +0100
commitaa86b62d7907f75d956d9bcf988c986c0cec231c (patch)
tree65fad97bb25ecd1c13cb14f4d9298682a52632d9
parentbc53abe0b6fd969906f371735a34a17ef5b6de70 (diff)
downloadtekuti-aa86b62d7907f75d956d9bcf988c986c0cec231c.tar.gz
tekuti-aa86b62d7907f75d956d9bcf988c986c0cec231c.zip
simpler caching algorithm
* tekuti/cache.scm: Simpler LRU algorithm for the cache. Conses more, but throws away the cache less.
-rw-r--r--tekuti/cache.scm9
1 files 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)
+ '())))