PEAR::Cache/Cache_Function
| From: | Boget, Chris | Date: | Wed, 01 Jan 2003 01:27:56 +0000 |
| Subject: | PEAR::Cache/Cache_Function | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-3119@lists.php.net to get a copy of this message | ||
I'm trying to use the cache_function class and I've run
into a brick wall and I'm hoping someone can help. I've
looked over the code and I just can't figure it out.
What if you need to call a function that contains multiple
(mixed) parameters?
Here's a simplified example of what I'm trying to do:
<?
$cache = new Cache_Function( 'file',
array( 'cache_dir' => './cache' ));
$cacheID = $cache->generateID( 'test_id' );
if( $data = $cache->get( $cacheID )) {
echo "Cache hit:<br>\n";
echo $data;
} else {
$stringVar = "Test";
$parameters = array( 'query' => 'select * from links' );
$myClass = new myClass();
$result = $cache->call( 'myClass->myFunc',
array( 'stringVar', 'parameters' ));
?>
But that's not working. How can I pass multiple arguments to
myClass->myFunc() via cache->call()?
Any help would be greatly appreciated!!
Also, if someone could point the direction to some really good
(and hopefully comprehensive) tutorials on using PEAR's Cache,
I'd very much appreciate that as well!!
Also, slight tangent - one minor point. I would think that the
Cache container (Function, File, DB, etc) object's methods,
especially the constructor, should conform to the definition
(signature?) of the Cache class methods. Unless I'm missing some-
thing or am misunderstanding OOP (and interfaces), I should just
be able to instantiate a Cache object, use the container param
to pass, say, 'function' and access the function container class'
methods as such:
$cache->container->whatever();
But the way some of the container classes are written, they aren't
using the same number of parameters. So if I wanted to overrride,
say, the container options parameter (to specify, say, a different
cache directory) I would have to instantiate the container class and
I couldn't go through the Cache base class. I don't know if that was
intentional or not but I would think that all I would need to
include/instantate would be the Cache class to Cache anything (because
the member variable container holds the actual instantiation of the
container class) and not have to worry about instantiating all these
differenct classes to Cache whatever I need to.
This is just an observation I made as I was reading through the code.
Again, I may be totally mistaken about this...
Chris