Brian Szymanski > Cache-Static > Cache::Static

Download:
Cache-Static-0.9905.tgz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.9905   Source  

NAME ^

Cache::Static - Caching without freshness concerns

SYNOPSIS ^

HTML::Mason instructions

In handler.pl: use Cache::Static;

In any component you where you have a well defined set of dependencies which change the output:

  <%init>
  my $_cs_deps = [
  #file dependencies - only regenerate if a file has changed
    'file|/path/to/some_configuration_file',

  #DBI dependencies - still under development - WONT WORK
  #DBI dependencies: note the third argument is a DSN
    '_DBI|table|mysql:scache_test_db|test_table',
    '_DBI|db|mysql:scache_test_db',

  #not yet implemented:
  #column level depends, e.g. "DBI|column|$dsn|$tablename|$columname"
  #row depends, e.g. "DBI|row|$dsn|$tablename|$uid_column_name|$uid_value"

  #XML::Comma dependencies - only regenerate if a Doc or Store has changed
    "_XML::Comma|Doc|$doc_key",
    "_XML::Comma|Store|$def|$store",

  #time dependencies (WARNING: these are discouraged, see doc/NOTE-time-deps)
    'time|15s', #every 15 seconds
    'time|M:15s', #every 15 seconds after the minute
    'time|H:2m', #every 2 minutes past the hour
    'time|W:2d3h5m0s', #every Tuesday at 3:05 AM

  #modifiers (indicate behavior when the file cannot be found)
    'file-0|/tmp/foo', #if ! -e /tmp/foo, regenerate
    'file-1|/tmp/foo', #if ! -e /tmp/foo, serve
    'file|/tmp/foo',   #use config value "dep_file_not_found_returns"

  #note modifiers also work on extensions, e.g.
    '_DBI-1|db|mysql:scache_test_db',
    '_XML::Comma-0|Store|mm_item|post',

  #etc... but modifiers CANNOT be used with times (since they have no
  #file backing on disk)
  ];

  #whatever you have in $_cs_deps above...
  return if Cache::Static::HTML_Mason_Util::cache_it($r, $m, 1, $_cs_deps);

  #...
  #rest of init block
  #...
  </%init>

Other Usage

TODO: an overview (and decent API) for usage outside of HTML::Mason land.

DESCRIPTION ^

  The guts of Cache::Static, in all its glory.

AUTHOR ^

  Brian Szymanski <scache@allafrica.com>

SEE ALSO ^

  http://chronicle.allafrica.com/scache/
syntax highlighting: