Maddy has asked for the wisdom of the Perl Monks concerning the following question:

I searched the web but couldn't find anything about this. If I hold the Refresh Key F5 my perl script dies with Couldn't rename CGI_Cache\content\4\5\3\4534b4c894c4e72ddb0480068c379c5dad798c0e.tmp1984 to CGI_Cache\content\4\5\3\4534b4c894c4e72ddb0480068c379c5dad798c0e at C:/Perl/site/lib/Cache/FileBackend.pm line 572. This happens occasionally. did I do anything wrong, or is this a multi-user problem with CGI-Cache called from several processes with the same key. Why are the files renamed ? They are not expired yet ! I am using Perl 5.8 CGI::Cache installed with ppm ( ActiveState ) WIN 2003 Server standard IIS 6 ( latest ) Could anyone help me with this ? here some of the code :
use CGI::Cache; #Set up cache CGI::Cache::setup( { cache_options => { cache_root => 'CGI_Cache', namespace => 'content', + max_size => 2 * 1024 * 1024 * 1024 , default_expires_in => (24-(localtime(time))[2] +).' hours', # stderr_filehandle => $stderr, } } ); my @cachekey=@parameter; CGI::Cache::set_key(@cachekey); $cacheit=1; CGI::Cache::start() or eval {$dbh = GetSql->disconnect_dbi(1) if $dbh +; $elapsed=tv_interval ( $gettimeref ); exit;}; CGI::Cache::stop() if $cacheit;

Replies are listed 'Best First'.
Re: CGI::Cache problems in FileBackend.pm
by perrin (Chancellor) on Apr 20, 2005 at 19:16 UTC
    It doesn't say anything more than that in the error message? The actual problem should be listed there, after a semi-colon.

    It always writes data to a temp file and then renames to the real file name in order to get atomic updates without using locking.

      no, but the or in Filebackend.pm applies. I guess that the operating system fails to rename because the file CGI_Cache\content\4\5\3\4534b4c894c4e72ddb0480068c379c5dad798c0e is in use by another process. It seems that this is not multi-user :-(
      rename( $temp_path, _Untaint_Path( $p_path ) ) or throw Error::Simple( "Couldn't rename $temp_path to $p_path" );
      both files exist and are not write protected or anything else...
        Most likely it means that it doesn't work on Windows. This is a completely safe operation on unix systems.