Class-Std-Fast

 view release on metacpan or  search on metacpan

lib/Class/Std/Fast.pm  view on Meta::CPAN

The object cache trades speed for memory. This is a very perlish way for
adressing performance issues, but may cause your application to blow up
if you're short of memory.

On a 32bit Linux, Devel::Size reports 44 bytes for a Class::Std::Fast based
object - so a cache containing 1 000 000 (one million) of objects needs
around 50MB of memory (Devel Size only reports the memory use it can see -
the actual usage is system dependent and something between 4 and 32 bytes
more).

If you are anxious about falling short of memory, only enable caching for
those classes whose objects you know to be frequently created and destroyed,
and leave it turned off for the less frequently used classes - this gives you
both speed benefits, and avoids holding a cache of object that will never be
needed again.

=head1 DIAGNOSTICS

see Class::Std.

Additional diagnostics are:

=over

=item * Class::Std::Fast loaded too late - put >use Class::Std::Fast< somewhere at the top of your application (warning)

Class::Std has been "use"d before Class::Std::Fast. While both classes
happily coexist in one application, Class::Std::Fast must be loaded first
for maximum speedup.

This is due to both classes overwriting UNIVERSAL::can. Class::Std::Fast uses
the original (fast) can where appropritate, but cannot access it if
Class::Std has overwritten it before with it's (slow) replacement.

=back

=head1 CONFIGURATION AND ENVIRONMENT

=head1 DEPENDENCIES

=over

=item *

L<version>

=item *

L<Class::Std>

=item *

L<Carp>

=back

=head1 INCOMPATIBILITIES

see L<Class::Std>

=head1 BUGS AND LIMITATIONS

=over

=item * You can't use the :SCALARIFY attribute for your Objects.

We use an increment for building identifiers and not Scalar::Util::refaddr
like Class::Std.

=item * Inheriting from non-Class::Std::Fast modules does not work

You cannot inherit from non-Class::Std::Fast classes, not even if you
overwrite the default constructor. To be more precise, you cannot inherit
from classes which use something different from numeric blessed scalar
references as their objects. Even so inheriting from similarly contructed
classes like Object::InsideOut could work, you would have to make sure that
object IDs cannot be duplicated. It is therefore strongly discouraged to
build classes with Class::Std::Fast derived from non-Class::Std::Fast classes.

If you really need to inherit from non-Class::Std::Fast modules, make sure
you use Class::Std::Fast::ID as described above for creating objects.

=item * No runtime initialization with constructor => 'basic' / 'none'

When eval'ing Class::Std::Fast based classes using the basic constructor,
make sure the last line is

 Class::Std::Fast::initialize();

In contrast to Class::Std, Class::Std::Fast performs no run-time
initialization when the basic constructor is enabled, so your code has to
do it itself.

The same holds true for constructor => 'none', of course.

CUMULATIVE, PRIVATE, RESTRICTED and anticumulative methods won't work if you
leave out this line.

=back

=head1 RCS INFORMATIONS

=over

=item Last changed by

$Author: ac0v $

=item Id

$Id: Fast.pm 469 2008-05-26 11:26:35Z ac0v $

=item Revision

$Revision: 469 $

=item Date

$Date: 2008-05-26 13:26:35 +0200 (Mon, 26 May 2008) $

=item HeadURL



( run in 1.814 second using v1.01-cache-2.11-cpan-39bf76dae61 )