Cache::File のメモ
2006-10-17-1
[Programming]
いまさらですが、手軽で便利ですね、Cache::File。
手元にあるいろいろな Perl プログラムをキャッシュ化中。
Chris Leishman / Cache-2.04 - search.cpan.org
http://search.cpan.org/~cleishman/Cache-2.04/
追記:
- [を] Cache::File で Storable[2006-10-24-6]
- [を] Cache::File の cache_umask[2006-11-27-5]
手元にあるいろいろな Perl プログラムをキャッシュ化中。
Chris Leishman / Cache-2.04 - search.cpan.org
http://search.cpan.org/~cleishman/Cache-2.04/
#!/usr/bin/perl use strict; use warnings; use Cache::File; my $cache = Cache::File->new(cache_root => '/var/tmp/cache-test', lock_level => Cache::File::LOCK_LOCAL(), default_expires => '3 weeks'); my $key = "Yokuaru Namae"; my $data = $cache->get($key); if ($data) { print "$key -> $data\n"; } else { $data = "Taro Yamada"; $cache->set($key, $data, '10 minutes'); } $key = "1374"; my Cache::Entry $entry = $cache->entry($key); if ($entry->exists()) { $data = $entry->get(); } else { $data = "imi nashi san kyuu"; $entry->set($data, '10 minutes'); } print $entry->key(), " -> ", $entry->get(), "\n"; print "size = ", $entry->size(), "\n"; $entry->set_expiry('10 minutes'); #$entry->remove();
追記:
- [を] Cache::File で Storable[2006-10-24-6]
- [を] Cache::File の cache_umask[2006-11-27-5]