| 1 | # | ||
| 2 | # This file is part of WebDyne. | ||
| 3 | # | ||
| 4 | # This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>. | ||
| 5 | # | ||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||
| 8 | # | ||
| 9 | # Full license text is available at: | ||
| 10 | # | ||
| 11 | # <http://dev.perl.org/licenses/> | ||
| 12 | # | ||
| 13 | package WebDyne::Cache; | ||
| 14 | |||
| 15 | |||
| 16 | # Compiler Pragma | ||
| 17 | # | ||
| 18 | use strict qw(vars); | ||
| 19 | use vars qw($VERSION); | ||
| 20 | use warnings; | ||
| 21 | no warnings qw(uninitialized); | ||
| 22 | |||
| 23 | |||
| 24 | # WebDyne Modules. | ||
| 25 | # | ||
| 26 | use WebDyne::Constant; | ||
| 27 | use WebDyne::Util; | ||
| 28 | |||
| 29 | |||
| 30 | # Version information | ||
| 31 | # | ||
| 32 | $VERSION='3.028'; | ||
| 33 | |||
| 34 | |||
| 35 | # Debug | ||
| 36 | # | ||
| 37 | 0 && debug("%s loaded, version $VERSION", __PACKAGE__); | ||
| 38 | |||
| 39 | |||
| 40 | # And done | ||
| 41 | # | ||
| 42 | 1; | ||
| 43 | |||
| 44 | #------------------------------------------------------------------------------ | ||
| 45 | |||
| 46 | |||
| 47 | sub import { | ||
| 48 | |||
| 49 | |||
| 50 | # Will only work if called from within a __PERL__ block in WebDyne | ||
| 51 | # | ||
| 52 | my ($class, @param)=@_; | ||
| 53 | my $self_cr=UNIVERSAL::can(scalar caller, 'self') || return; | ||
| 54 | my $self=$self_cr->() || return; | ||
| 55 | my %param=(@param == 1) ? (cache => @param) : @param; | ||
| 56 | my $meta_hr=$self->meta() || return err(); | ||
| 57 | $meta_hr->{'cache'}=$param{'cache'}; | ||
| 58 | $meta_hr->{'static'}=1; | ||
| 59 | |||
| 60 | } | ||
| 61 | |||
| 62 | |||
| 63 | sub handler : method { | ||
| 64 | |||
| 65 | |||
| 66 | # Handler is a no-op, all work is done by filter code. Need a handler so | ||
| 67 | # module is seen by WebDyne autoload method when tracking back through | ||
| 68 | # chained modules | ||
| 69 | # | ||
| 70 | my ($self, $r)=(shift, shift); | ||
| 71 | my $cache=$r->dir_config('WebDyneCacheHandler') || | ||
| 72 | return $self->err_html( | ||
| 73 | 'unable to get cache handler name - have you set the WebDyneCacheHandler var ?' | ||
| 74 | ); | ||
| 75 | $self->cache($cache); | ||
| 76 | $self->static(1); | ||
| 77 | $self->SUPER::handler($r, @_); | ||
| 78 | |||
| 79 | } | ||
| 80 | |||
| 81 | __END__ |