Index: openacs-4/packages/acs-admin/www/cache/flush-cache.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/cache/flush-cache.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/cache/flush-cache.tcl 7 Nov 2002 13:51:54 -0000 1.1 @@ -0,0 +1,18 @@ +ad_page_contract { + Flush one or more values from util_memoize's cache +} { + suffix +} + +if [string equal $suffix "util_memoize"] { + foreach name [ns_cache names util_memoize] { + ns_cache flush util_memoize $name + } +} else { + #ns_return 200 text/html $suffix + if [catch { util_memoize_flush_cache $suffix } errmsg] { + ns_return 200 text/html "Cannot flush the cache for $suffix suffix." + } +} + +ad_returnredirect "index" \ No newline at end of file Index: openacs-4/packages/acs-admin/www/cache/flush.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/cache/flush.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/cache/flush.tcl 7 Nov 2002 13:51:54 -0000 1.1 @@ -0,0 +1,35 @@ +ad_page_contract { + Flush one or more values from util_memoize's cache +} { + type + pattern + raw_date + key:allhtml +} + +if {[catch {set pair [ns_cache get util_memoize $key]} errmsg]} { + # backup plan, find it again because the key doesn't always + # pass through cleanly + set cached_names [ns_cache names util_memoize] + foreach name $cached_names { + if {[regexp -nocase -- $pattern $name match]} { + set pair [ns_cache get util_memoize $name] + set raw_time [lindex $pair 0] + if {$raw_time == $raw_date} { + set value [ad_quotehtml [lindex $pair 1]] + set time [clock format $raw_time] + set key $name + break + } + } + } + + if {![info exists value] || [string equal "" $value]} { + ad_return_complaint 1 "Could not retrieve" + } +} + + +ns_cache flush util_memoize $key + +ad_returnredirect "show-util-memoize?pattern=$pattern" \ No newline at end of file Index: openacs-4/packages/acs-admin/www/cache/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/cache/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/cache/index.adp 7 Nov 2002 13:51:54 -0000 1.1 @@ -0,0 +1,56 @@ + + Cache Control + "Cache data" +

util_memoize caches

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameEntriesFlushedHit RateSizeMax Size 
@caches.name@@caches.entries@@caches.flushed@@caches.hit_rate@%@caches.size@@caches.max@  + flush  +
+ +
+ Show names that contain + <% + #start with + #contain + %> + + +
+ +
+ Notes: +
    +
  • This currently only searches the primary "util_memoize" cache +
+
+
+ +
Index: openacs-4/packages/acs-admin/www/cache/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/cache/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/cache/index.tcl 7 Nov 2002 13:51:54 -0000 1.1 @@ -0,0 +1,29 @@ +ad_page_contract { +} { +} + +template::multirow create caches name entries size max flushed hit_rate + +foreach cache [lsort -dictionary [ns_cache_names]] { + if {[regexp {util_memoize_(.*)} $cache match suffix] \ + || [string equal $cache "util_memoize"]} { + if {![info exists suffix] || [string equal "" $suffix]} { + set name "util_memoize" + set match "util_memoize" + } else { + set name $suffix + } + set pair [ns_cache_size $match] + set size [format "%.2f MB" [expr [lindex $pair 1] / 1048576.0]] + set max [format "%.2f MB" [expr [lindex $pair 0] / 1048576.0]] + ns_cache_stats $match stats_array + set entries $stats_array(entries) + set flushed $stats_array(flushed) + set hit_rate $stats_array(hitrate) + template::multirow append caches $name $entries $size $max \ + $flushed $hit_rate + } + set match "" + set suffix "" +} + Index: openacs-4/packages/acs-admin/www/cache/one.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/cache/one.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/cache/one.adp 7 Nov 2002 13:51:54 -0000 1.1 @@ -0,0 +1,24 @@ + + util_memoize: @pattern@ + {./ "Cache data"} "one entry" + +
+ + + + + Cached value at @time@. + +
+
+ Key: +
+
@key@
+
+
+ Value: +
+ @value@ +
+ +

$Id: one.adp,v 1.1 2002/11/07 13:51:54 jeffd Exp $

Index: openacs-4/packages/acs-admin/www/cache/one.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/cache/one.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/cache/one.tcl 7 Nov 2002 13:51:54 -0000 1.1 @@ -0,0 +1,38 @@ +ad_page_contract { + Show the contents of one cached entry +} { + key:allhtml + pattern + raw_date +} + +if {[catch {set pair [ns_cache get util_memoize $key]} errmsg]} { + # backup plan, find it again because the key doesn't always + # pass through cleanly + set cached_names [ns_cache names util_memoize] + foreach name $cached_names { + if {[regexp -nocase -- $pattern $name match]} { + set pair [ns_cache get util_memoize $name] + set raw_time [lindex $pair 0] + if {$raw_time == $raw_date} { + set value [ad_quotehtml [lindex $pair 1]] + set time [clock format $raw_time] + set key $name + break + } + } + } + if {![info exists value] || [string equal "" $value]} { + set value "could not retrieve" + set time "?" + } +} else { + set value [ad_quotehtml [lindex $pair 1]] + set time [clock format [lindex $pair 0]] +} + +set safe_key [ad_quotehtml $key] + +regsub -all -nocase -- $pattern $key \ + "$pattern" key + Index: openacs-4/packages/acs-admin/www/cache/show-util-memoize.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/cache/show-util-memoize.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/cache/show-util-memoize.adp 7 Nov 2002 13:51:54 -0000 1.1 @@ -0,0 +1,66 @@ + + util_memoize: @pattern@ + {./ "Cache data"} search + + Search for @pattern@: + + + @matches:rowcount@ matches found.

+ + + Only the first 200 chars of key and value are shown. + View + full results. + + + Full strings for key and value shown. + View + short results. + + + + + + + + + + + + <% set bg "#eef8f8" %> + + + <% set bg "#f8f8ee" %> + + + + + + + + + + + +
keyvalue 
@matches.key@@matches.value@ +
+ + + + +
+
+ + Cached @matches.date@ - @matches.value_size@ bytes + +
+

+ + + no matches found + + +

$Id: show-util-memoize.adp,v 1.1 2002/11/07 13:51:54 jeffd Exp $

Index: openacs-4/packages/acs-admin/www/cache/show-util-memoize.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/cache/show-util-memoize.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-admin/www/cache/show-util-memoize.tcl 7 Nov 2002 13:51:54 -0000 1.1 @@ -0,0 +1,36 @@ +ad_page_contract { + Lists memoized data and gives options to view data or flush data +} { + {pattern_type "contain"} + pattern + {full "f"} +} + + +set cached_names [ns_cache names util_memoize] +# ns_log notice "ep_flush_list_cache found [llength $cached_names] names cached" + +template::multirow create matches key value value_size full_key date raw_date + +foreach name $cached_names { + if {[regexp -nocase -- $pattern $name match]} { + set key [ad_quotehtml $name] + set safe_key [ad_quotehtml $name] + if {[catch {set pair [ns_cache get util_memoize $name]} errmsg]} { + continue + } + set raw_date [lindex $pair 0] + set date [clock format $raw_date -format "%d %b %H:%M:%S"] + set value [ad_quotehtml [lindex $pair 1]] + set value_size [string length $value] + if {$full} { + template::multirow append matches $key $value $value_size \ + $safe_key $date $raw_date + } else { + template::multirow append matches [string range $key 0 200] \ + [string range $value 0 200] $value_size $safe_key \ + $date $raw_date + } + } +} +