Created
December 7, 2011 09:21
-
-
Save issm/1442136 to your computer and use it in GitHub Desktop.
2011-12-07.cache-filecache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use 5.12.0; | |
use warnings; | |
use FindBin; | |
use File::Find; | |
use Storable qw/thaw/; | |
use Data::Dumper; | |
my $target = "${FindBin::Bin}/cache"; | |
sub _do_something { | |
my ($f) = @_; | |
my ($raw, $data); | |
$raw = do { | |
my $a; | |
local $/; | |
open my $fh, '<', $f or die $!; | |
$a = <$fh>; | |
close $fh; | |
$a; | |
}; | |
$data = thaw($raw); | |
say Dumper $data; | |
} | |
sub _handle_found { | |
my $f = $File::Find::name; | |
return if -d $f; | |
return _do_something($f); | |
} | |
find \&_handle_found, $target; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use 5.12.0; | |
use warnings; | |
use FindBin; | |
use Cache::FileCache; | |
my $cache = Cache::FileCache->new({ | |
cache_root => "${FindBin::Bin}/cache", | |
namespace => 'mycache', | |
}); | |
$cache->set( | |
'hogehoge', | |
{ foo => 1, bar => 2, baz => [ 3, 4, 5 ] }, | |
600, | |
); | |
$cache->set( | |
'fugafuga', | |
[qw/ a b c d e /], | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment