Menu

#11 Class profusion confusion

open
nobody
None
5
2001-06-13
2001-06-13
No

So I was looking at this because we're going to be using it more and more
in Mason. I think we're going to want to use the
Cache::SizeAwareMemoryCache class except we need a version that does
expiration based on some sort of LRU system as well.

This leads to quite a crazy profusion of classes. I was thinking that
this could all be simplified (for the user, mind you ;) by making
Cache::Cache objects similar to the classless object system (see
Class::Classless).

I might request an object like this:

my $cache = Cache::Cache->new( storage => 'File',
attributes => [ 'MemoryAware', 'LRU' ] );

There would exist the following classes:

Cache::Storage::File
Cache::Attribute::MemoryAware
Cache::Attribute::LRU

The Cache::Cache code would generate a new class something like this:

eval <<"EOF";
package Cache::Cache::Sub$number;

use base qw( Cache::Storage::File Cache::Attribute::MemoryAware Cache::Attribute
::LRU );
EOF

return bless {}, 'Cache::Cache::Sub$number';

You could use Damian Conway's NEXT class to ensure that each class got a
crack at handling each method.

Anyway, its an idea.

-dave

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.