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] } }