blob: 25e5f0d0b69b5b1e4db8264ea88446b37782e03d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
namespace eval cache {
# Dictionary containing filename and contents pairs.
variable cache {};
proc hit {filename} {
variable cache
return [dict exists $cache $filename]
}
proc get {filename} {
variable cache
return [dict get $cache $filename]
}
proc add {filename} {
variable cache
set file [open $filename]
fconfigure $file -translation binary
dict append cache $filename [read $file]
}
proc remove {filename} {
variable cache
if [dict exists $cache $filename] {
set cache [dict remove $cache $filename]
}
}
#TODO: Pre-cache all precache files.
foreach i $precache {
add [string cat $::http::root $i]
}
}
|