From: Stephen D. <sd...@gm...> - 2006-07-24 20:14:50
|
Some people 'cache' content to disk in the form of Tcl pages. There's the logic in there that needs to run at page delivery time, plus some data from a db, for example. New Tcl pages are created as new content arrives, deleted as necessary. The ns:tclcache_* procs are only ever created. This is a cache of infinite size. It may be easier to just bite the bullet and create an ADP wrapper that simulates a single-chunk ADP page... On 7/22/06, Vlad Seryakov <ser...@us...> wrote: > Update of /cvsroot/naviserver/naviserver/tcl > In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv23802/tcl > > Modified Files: > file.tcl > Log Message: > Use wrapped Tcl proc aroun d.tcl file instead of not exactly as needed working global ns_cache for cacheing Tcl bytecode > > > Index: file.tcl > =================================================================== > RCS file: /cvsroot/naviserver/naviserver/tcl/file.tcl,v > retrieving revision 1.7 > retrieving revision 1.8 > diff -C2 -d -r1.7 -r1.8 > *** file.tcl 9 Mar 2006 11:25:55 -0000 1.7 > --- file.tcl 22 Jul 2006 02:24:09 -0000 1.8 > *************** > *** 53,57 **** > ns_register_proc POST /*.tcl ns_sourceproc > ns_register_proc HEAD /*.tcl ns_sourceproc > - ns_cache_create ns:filecache [ns_config $path filecachesize 5000000] > } > > --- 53,56 ---- > *************** > *** 86,126 **** > # > # Side effects: > ! # Caches the file content and Tcl_Obj's rep of the > ! # sourced script in per-thread cache (is this true?) > # > > ! proc ns_sourcefile {filename} { > ! > ! file stat $filename stat > ! set current_cookie $stat(mtime):$stat(ctime):$stat(ino):$stat(dev) > ! > ! # > ! # Read current cached file > ! # > ! > ! set pair [ns_cache_eval ns:filecache $filename { > ! list $current_cookie [ns_fileread $filename] > ! }] > > ! # > ! # If changed, re-cache it > ! # > > ! if {[lindex $pair 0] ne $current_cookie} { > ! ns_cache_flush ns:filecache $filename > ! set pair [ns_cache_eval ns:filecache $filename { > ! list $current_cookie [ns_fileread $filename] > ! }] > } > ! > ! # > ! # And here's the magic part. We're using "for" here to translate the > ! # text source file into bytecode, which will be associated with the > ! # Tcl_Obj we just cached (as its internal representation). "eval" > ! # doesn't do this as the eval provided in Tcl uses the TCL_EVAL_DIRECT > ! # flag, and hence interprets the text directly. > ! # > ! > ! uplevel [for [lindex $pair 1] {0} {} {}] > } > > --- 85,107 ---- > # > # Side effects: > ! # Each .tcl file will be wrapped into Tcl proc in every thread > # > > ! proc ns_sourcefile { path } { > > ! set proc0 [info procs ns:tclcache_$path] > ! file stat $path stat > ! set cookie0 $stat(mtime):$stat(ctime):$stat(ino):$stat(dev) > > ! # Verify file modification time > ! if { $proc0 == "" || [$proc0 1] != $cookie0 } { > ! set code [ns_fileread $path] > ! proc ns:tclcache_$path { {getcookie 0} } " > ! if { \$getcookie } { return $cookie0 } > ! $code > ! " > } > ! # Run the proc > ! ns:tclcache_$path > } > > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > naviserver-commits mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-commits > |