1 package SL::System::ResourceCache;
7 our @paths = qw(image css);
15 File::Find::find(sub {
16 $cache->{ $File::Find::name =~ s{^\./}{}r } = stat($_);
21 my ($class, $file) = @_;
24 return stat($file) if ($::dispatcher // { interface => 'cgi' })->{interface} eq 'cgi';
26 $class->generate_data;
39 SL::System::ResourceCache - provides access to resource files without having to access the filesystem all the time
43 use SL::System::ResourceCache;
45 SL::System::ResourceCache->get($filename);
49 This will stat() all files in the configured paths at startup once, so that
50 subsequent calls can use the cached values. Particularly useful for icons in
51 the menu, which would otherwise generate a few hundred file sytem accesses per
54 The caching will not happen in CGI and script environments.
60 =item * C<get FILENAME>
62 If the file exists, returns a L<File::stat> object. If it doesn't exists, returns undef.
72 Make into instance cache and keep it as system wide object
76 Sven Schöling E<lt>sven.schoeling@googlemail.comE<gt>