You should describe more details of your application to get some reliable answers, imho... Is it CGI or pure mod_perl? Apache 1 or 2?
It is web application running on mod_perl 1 with apache 1.3. But the classes that implements business objects basically don't care if it runs under mod_perl or from command line. They only need the database with a certain schema.
How many rows exist in db tables and how complex queries are?
There could be more than a million record in the cache table. The operation on the table is basically like this (in perl-like pseudocode):
sub search
{
my ($arrival_date, $departure_date, $number_of_guests) = @_;
validate_search_cache($arrival_date, $departure_date);
my @search_results = ... do SELECT query to get a list of available
+ room-package combination between $arrival_date and $departure date f
+or $number_of_guests ...
return @search_results;
}
sub validate_search_cache
{
my ($arrival_date, $departure_date) = @_;
my @validated_dates = ... do SELECT query that returns a list of da
+tes between $arrival_date and $departure_date having valid combinatio
+ns of room-package ...
my @invalid_dates = ... look for dates between $arrival_date and $d
+eparture_date that doesn't exists in @validated_dates ...
foreach (@invalid_dates) {
initialize_search_cache($_);
}
}
my @field_list = (
{
name => 'valid_price',
op => sub { ... computation to check if price valid on
a certain date ... },
},
{
name => 'available_room_count',
op => sub { ... calculcation to get the available room
count on a certain date ... },
},
...
);
sub initialize_search_cache
{
my ($date) = @_;
my @keys;
my @values;
foreach (@field_list) {
push @keys, $_->{name};
push @values, $_->{op}->($date);
}
my $sth = $dbh->prepare("INSERT INTO (".(join ',', @keys).") VALUES
+ (".(join ',', map "?", @values).")";
$sth->execute(@values);
}
I hope that explains how the code works. The queries are mostly simple, except when doing the search for availability.
badaiaqrandista
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.