揮発性のメモ2

http://d.hatena.ne.jp/iww/

FuelPHPでセッションがタイムアウトしたときに削除されるタイミング

fuelphp 1.7.2
$COREPATH/session/file.php

<?
// do some garbage collection
if (mt_rand(0,100) < $this->config['gc_probability'])
{
    if ($handle = opendir($this->config['path']))
    {
        $expire = $this->time->get_timestamp() - $this->config['expiration_time'];

        while (($file = readdir($handle)) !== false)
        {
            if (filetype($this->config['path'] . $file) == 'file' and
                strpos($file, $this->config['cookie_name'].'_') === 0 and
                filemtime($this->config['path'] . $file) < $expire)
            {
                @unlink($this->config['path'] . $file);
            }
        }
        closedir($handle);
    }
}

mt_rand()の戻り値は両端含まれるから、これ gc_probability=100 に設定してても消されないときあるな。
まあ大したバグじゃないからどうでもいいか。


ところで、なんでセッション管理のガベコレってどの言語でも「確率で削除」がまかり通っているんだろ。
処理能力的な話なのかな。 気になる