Help for this page

Select Code to Download


  1. or download this
      my $lock = "/tmp/lock_foo";
      if( ! -f $lock || time - (stat($lock))[9] > 600 ){
    ...
        open FILE '>', $lock;
        # optionally write info/details to it
      }
    
  2. or download this
    use Cache::FileCache;
    my $cache = new Cache::FileCache( { namespace=>"TimeLocks" } );
    ...
      # do stuff
      $cache->set( $key, time, "10 minutes" );  # note the value could jus
    +t be '1', or any other true value.
    }