Posted by slantview on June 17, 2010 at 9:42pm
I created a wiki for discussion about the future of Drupal Caching. Please read http://groups.drupal.org/node/75823 and let's discuss in here to figure out how to create a Cache API v2 that surpasses our current implementation.

Comments
Smarter defaults
I don't know how this fits in but for
$conf['memcache_key_prefix']I use this so my multi-site gets setup quicker.<?php$conf['memcache_key_prefix'] = array_pop(explode('/', str_replace("\\", '/', realpath(conf_path()))));
?>
If we implemented smarter defaults, that would go a long way in terms of things just working out of the box.
using your 'convenience'
using your 'convenience' string as above, at nav to my front page, i get
Strict warning: Only variables should be passed by reference in include_once() (line 136 of /srv/www/test/sites/default/settings.php).
where, at my settings.php
<?php
$conf += array(
...
136 'memcache_key_prefix' => array_pop(explode('/', str_replace("\\", '/', realpath(conf_path())))),
...
?>
this is on a new server with php 5.4 installed. i do not recall seeing any such error on php 5.3 ... i'll start to look in the php docs, but if you have any clues?
thanks.
array_pop accepts a reference
array_pop accepts a reference as first param. As explode doesn't return a reference, PHP throws a warning. Assign the return value from explode to a variable, then pass this variable to array_pop.
See http://www.php.net/array_pop
Updated
This is what we use now.
<?php$conf_path = str_replace("\\", '/', realpath(conf_path()));
$conf['memcache_key_prefix'] = substr($conf_path, strrpos($conf_path, '/')+1);
?>
What this is equivalent to if running on the default site.
$conf['memcache_key_prefix'] = 'default';Why all the function calls?
Why all the function calls? Assuming each multi-site lives in its own directory at ./sites/department.domain.com you could find the current site pretty easily by just doing this in your site's settings.php:
<?php// ./sites/department.domain.com/settings.php
$conf['memcache_key_prefix'] = basename(__DIR__); // sets as "department.domain.com"
?>
php 5.3.0
The __DIR__ magic constant was added in php 5.3. Drupal 7 supports 5.2+
OK, here's the 5.2-compatible
OK, here's the 5.2-compatible version if you're stuck using a PHP version that's end-of-life:
<?php// ./sites/department.domain.com/settings.php
$conf['memcache_key_prefix'] = basename(dirname(__FILE__)); // sets as "department.domain.com"
?>
One more thing
Now I remember why I use conf_path to do this. We have a fairly large multi site and inside of settings.php we do an include to a file that has an array of all the database names and connections etc... makes management a lot simpler. Doing this also breaks the magic function names; and having something built into memcache would be the best way forward http://drupal.org/node/1324812#comment-5365326
iiuc that this is what you
iiuc that this is what you had in mind,
<?php$key_prefix_explode = explode('/', str_replace("\", '/', realpath(conf_path())));
$conf += array(
...
'memcache_key_prefix' => array_pop($key_prefix_explode),
...
?>
that works. at least, it no longer complains.
thanks.