Skip to content

Commit 66e7219

Browse files
committed
Allow flushed servlet instances to be specified.
1 parent 898195b commit 66e7219

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

web-server-lib/web-server/dispatchers/dispatch-servlets.rkt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,21 @@
2323
[make-cached-url->servlet
2424
(-> url->path/c
2525
path->servlet/c
26-
(values (-> void)
26+
(values (() ((or/c false/c (listof url?))) . ->* . void?)
2727
url->servlet/c))])
2828

2929
(define (make-cached-url->servlet
3030
url->path
3131
path->servlet)
3232
(define config:scripts (make-cache-table))
33-
(values (lambda ()
33+
(values (lambda ([uris #f])
3434
;; This is broken - only out of date or specifically mentioned scripts should be flushed. This destroys persistent state!
35-
(cache-table-clear! config:scripts))
35+
(cache-table-clear!
36+
config:scripts
37+
(and uris
38+
(for/list ([uri (in-list uris)])
39+
(let-values ([(servlet-path _) (url->path uri)])
40+
(string->symbol (path->string servlet-path)))))))
3641
(lambda (uri)
3742
(define-values (servlet-path _)
3843
(with-handlers

web-server-lib/web-server/private/cache-table.rkt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88
(make-cache-table (make-hasheq)
99
(make-semaphore 1)))
1010

11-
(define (cache-table-clear! ct)
11+
(define (cache-table-clear! ct [entry-ids #f])
1212
(call-with-semaphore
1313
(cache-table-semaphore ct)
1414
(lambda ()
15-
(set-cache-table-hash! ct (make-hasheq)))))
15+
(if entry-ids
16+
(let ([cache-hash (cache-table-hash ct)])
17+
(for ([entry-id (in-list entry-ids)])
18+
(hash-remove! cache-hash entry-id)))
19+
(set-cache-table-hash! ct (make-hasheq))))))
1620

1721
(define (cache-table-lookup! ct entry-id entry-thunk)
1822
(define ht (cache-table-hash ct))
@@ -31,5 +35,5 @@
3135
[rename new-cache-table make-cache-table
3236
(-> cache-table?)]
3337
[cache-table-lookup! (cache-table? symbol? (-> any/c) . -> . any/c)]
34-
[cache-table-clear! (cache-table? . -> . void?)]
38+
[cache-table-clear! ((cache-table?) ((or/c false/c (listof symbol?))) . ->* . void?)]
3539
[cache-table? (any/c . -> . boolean?)])

0 commit comments

Comments
 (0)