changeset 29:420807d41e04

Updating comments
author Dominic Cleal <dominic@computerkb.co.uk>
date Sun, 25 Jan 2009 17:38:56 +0000
parents 61fb1a6de2c5
children d1028107ab75
files reproctool.cgi
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/reproctool.cgi	Sun Jan 25 17:36:03 2009 +0000
+++ b/reproctool.cgi	Sun Jan 25 17:38:56 2009 +0000
@@ -41,10 +41,9 @@
 my $str_items = $cgi->param('items');
 
 # Generate the first page, where eve-central mineral prices are prefilled.
-# TODO: depending on the traffic, cache these eve-central prices.
-
 unless ($str_items)
 {
+    # Try and pull the marks out of a stored cache
     my $marks;
     if (-e $marks_cache)
     {
@@ -52,6 +51,7 @@
         $marks = fd_retrieve(*CACHE) || die("Can't read marks from cache: $!");
         close CACHE;
         
+        # Check expiry time
         if (time > ($marks->{timestamp} + $marks_cache_expiry))
         {
             $marks = undef;
@@ -60,12 +60,14 @@
     
     unless ($marks)
     {
+        # If cache was unavailable or had expired, pull again from eve-central
         my $ua = LWP::UserAgent->new;
         $ua->agent('reproctool');
         my $resp = $ua->request(HTTP::Request->new(GET => $eve_central_url));
         
         if ($resp->is_success)
         {
+            # Store as Mineral => 1234
             $marks = { timestamp => time };
             foreach (split(/[\n\r]/, $resp->content))
             {
@@ -79,6 +81,7 @@
                     || die("Unable to unlink cache $marks_cache: $!");
             }
             
+            # Store into the cache
             open CACHE, "> $marks_cache"
               || die("Can't open cache $marks_cache to write: $!");
             store_fd($marks, *CACHE) || die("Can't write to cache: $!");
@@ -86,6 +89,7 @@
         }
         else
         {
+            # User can enter their own numbers if eve-central was down
             $marks->{$_} = 1 foreach ('Tritanium', 'Pyerite', 'Mexallon',
                                       'Isogen',    'Nocxium', 'Zydrine',
                                       'Megacyte',  'Morphite');