Cache design

From: Date: Thu, 01 Mar 2001 18:04:07 +0000
Subject: Cache design
References: 1  Groups: php.pear 
Request: Send a blank email to php-pear+get-1534@lists.php.net to get a copy of this message
Hi, Christian Stocker wrote: > i made yesterday and today a proposal to ulf and vinai, how the whole > thing could be done a little bit different (i'm not very happy with the > fact that the class Cache calls another class. i think, it should go the > other way round, so that the container classes extend the base class and > one calls the container class directly). now, i know why there was no > answer from ulf... if i feel to, i maybe post it here, too. or go to > http://cvs.nomad.ch/index.cgi/pear/Cache/ and look at base.php > and > Container/db2.php, they do that already (with some flaws naturally). and > feel free to do with it whatever you want :) I read that posting, did not 100% get what you mean but I guess I had a similar feeling about the design, but it's ok. We now have this structure: Function Cache Output Cache Graphics Cache ^ | extends | Cache This is absolutely perfect. The're a generic base class Cache that caches data. Now we wanted an abstraction for the storage container. So we all looked at PHPLib session implementation where we find a controller/supplier structure for the storage container. Cache --- uses --> Cache_Container Container_File Container_XY ^ | extends | Cache_Container Cache_Container implements the interface we need, Container_XY overrides the abstract methods. Cache acts as a wrapper for it's supplier Cache_Container and offers some methods itself. This is a perfect OO design. Now, when we start to implement it, well see that Cache does not offer that many methods that can't be placed into Cache_Container and we might get worried about the "overhead". Ok, lets change the structure and throw Cache away to see what happens. Output_Cache ^ | extends | Container_XY Now I'd like to combine a certain Cache type (Output, Function, Graphics, ...) and with a certain storage type (File). What do I have to do? Change my code so that type x extends storage y. This is not very flexible as I can't do this as runtime. So I'd put x multiply y combination on my hard disk... :/. It's a bad idea to kick the Cache class. Ulf

« previous php.pear (#1534) next »