たつをの ChangeLog

9 件 見つかりました。

1 2 [ 次へ ]

CGI からは Cache::File は使わないことにした
  • https://chalow.net/2008-08-29-3.html
  • CGI からは Cache::File は使わないことにした[Maintenance] 先日、私が借りているさくらのレンタルサーバのうちの一つで、全ての CGI が動かなくなっていた。EReK や発想支援ナビや Wadazon など 10 個ほどのサービスを動かしているサーバー(ref. [2008-08-24-3])。原因はある CGI (perl) で使っていた Cache::File モジュール。キャッシュ管理用のファイルが壊れているかロックされているかで、その CGI がいくつも暴走していて、負荷が上がったのが原因。こういうことはこれまでも度々あったので、安定運用のため、今後、この手の CGI では Cache::File を使用しないことにする。って、 Cache::File を使っていたのって、この CGI だけだったんだけどね。他はアクセス時に静的 HTML ファイルを生成する方式。Expire の処理は cron に任せている。いちいち CGI 内からやられてもねえ。
Cache::Fileメモ
  • https://chalow.net/2007-04-29-1.html
  • Cache::Fileメモ[Programming] CGI + HTML::Template で Cache::File を使うときの自分用メモ、SYNOPSIS。my $cache_root_root = "/home/yto/www/foobar/cache";my $cache_page = Cache::File->new(cache_root => $cache_root_root."/page", cache_umask => 000, default_expires => '48 hours', size_limit => 10000000,);if (defined $cache_page and $key !~ /^\s*$/) { my $data = $cache_page->get($key); if ($data) { print decode('utf8', $data); print qq(<!-- cached file -->\n); exit; }}...my $template = join("", <DATA>);my $t = HTML::Template->new(scalarref => \$template, loop_context_vars => 1, global_vars => 1, die_on_bad_params => 0);...my $out = $t->output();if ($cache_page and $key !~ /^\s*$/) { $cache_page->set($key, $out);}print $out;
Cache::File の cache_umask
  • https://chalow.net/2006-11-27-5.html
  • Cache::File の cache_umask[Programming] Perl の話題。Cache::File [2006-10-17-1]を使ってたら、キャッシュディレクトリ&ファイルのパーミッションが問題になった。例えば、apache とコマンドラインの両方から呼ぶような場合、どちらかでキャッシュを書き込むともう一方では読み書きできない。はまった。この問題に対処するには、コンストラクタで cache_umask を設定すると良いみたい。例:Cache::File->new(cache_root => $cache_root_dir, cache_umask => 000, ...ref.- perldoc- Google Code Search : cache_umask
Cache::File で Storable
  • https://chalow.net/2006-10-24-6.html
  • Cache::File で Storable[Programming] 勉強になります。[を] Data::Dumper で eval するメモ[2006-10-24-2]Cache::FileでStoreblaを使いたいのだが、できそうもないので(何か良い方法があったら教えて下さい)、に対して、404 Blog Not Found:perl - Cache::File と Storablehttp://blog.livedoor.jp/dankogai/archives/50668036.html出来ます、というよりCacheははじめからStorableをサポートしてます。とのこと。ありがとうございます。thaw, freeze ってこういう用途に使うものなのですね。調べが足りなく反省。しかし、教えていただいてツイてる!以下、「学んだら作る」サンプルプログラム:#!/usr/bin/perluse strict;use warnings;use Cache::File;my $cache = Cache::File->new(cache_root => "/var/tmp/cache", default_expires => '1 hour');my $foo = $cache->thaw("test");if ($foo) { print "out : ";} else { print "in : "; $foo = [ 0, [1,2,3], "hello", {one => 1, two => 2} ]; $cache->freeze("test", $foo);}#$cache->clear();print $foo->[0], " ";print join(",", @{$foo->[1]}), " ";print $foo->[2], " ";print join(",", map {"$_:$foo->[3]{$_}"} keys %{$foo->[3]}), "\n";以下、実行結果。一回目の実行でキャッシュに入れて、それ以降の実行では取り出します。% perl test.plin : 0 1,2,3 hello one:1,two:2% perl test.plout : 0 1,2,3 hello one:1,two:2% perl test.plout : 0 1,2,3 hello one:1,two:2
Data::Dumper で eval するメモ
  • https://chalow.net/2006-10-24-2.html
  • Data::Dumper で eval するメモ[Programming] Cache::File[2006-10-17-1]でStorebla[2006-05-09-2]を使いたいのだが、できそうもないので(何か良い方法があったら教えて下さい。追記: ありました!→[2006-10-24-6])、Data::Dumper でシリアライズして読み書きすることにした。サンプルプログラム:#!/usr/bin/perluse strict;use warnings;use Data::Dumper;$Data::Dumper::Terse = 1;$Data::Dumper::Indent = 0;my $foo = [ 0, [1,2,3], "hello", {one => 1, two => 2} ];my $text = Dumper($foo); # シリアライズprint "\$foo = $text\n";my $bar = eval $text; # もどすprint "\$bar = ", Dumper($bar), "\n";print "test : ";print $bar->[0], " ";print join(",", @{$bar->[1]}), " ";print $bar->[2], " ";print join(",", map {"$_:$bar->[3]{$_}"} keys %{$bar->[3]}), "\n";実行結果:% perl dd.pl$foo = [0,[1,2,3],'hello',{'one' => 1,'two' => 2}]$bar = [0,[1,2,3],'hello',{'one' => 1,'two' => 2}]test : 0 1,2,3 hello one:1,two:2Terse をセットすると最初に出てくる変数($VAR1など)が出なくなり、Indent をオフにするとインデントや改行がなくなる。see perldoc参考:- Data::Dumper - perlデータ構造の出力/eval両用文字列化 http://fleur.hio.jp/perldoc/mix/lib/Data/Dumper.ja.html

1 2 [ 次へ ]

たつをの ChangeLog
Powered by chalow