in reply to Re: How to cache a regular expression in a DBIx::Class object
in thread How to cache a regular expression in a DBIx::Class object

Thank you for replying. Unfortunately I have tried that and it did not work.

When processing log output, I set a breakpoint in the perl debugger on the second line of the input file. (using $DB::single=1 if 0  != $INPUT_LINE_NUMBER)

When I hit that breakpoint I stepped into the $watch_string->match_re() method and found that the regular expression that should have been cached was not there. It looks like DBIx::Class was re-creating objects every time.

There are about 10 rows in the tblWatchString table, so I would not have thought that objects would be cleared as part of a memory saving or garbage collection system.

Replies are listed 'Best First'.
Re^3: How to cache a regular expression in a DBIx::Class object
by moritz (Cardinal) on Apr 09, 2011 at 11:31 UTC
    It looks like DBIx::Class was re-creating objects every time.

    Oh, I missed that part. There's a much easier for that - move the retrieval of the DBIx::Class objects out of the loop:

    my @watchstrings = $schema->resultset('WatchString')->all while( my $line <INPUT> ) { for my $w (@watchstrings) { ... } }