A few questions and ideas on Drupal variables and cache.
Variables are stored by name. variable_set($name, $value)
accepts a name and a value. I can tell the name of variables for module free_beer because the variable size_of_glass is named free_beer_size_of_glass. I can set the value using variable_set('free_beer_size_of_glass', '5 litre');
. Would it be possible long term to have the module name separate?
My own code does the equivalent of the following. The only difference is that it is done automatically in classes.
$free_beer = variable_get('free_beer', array());
$free_beer['size_of_glass'] = '5 litre';
variable_set('free_beer', $free_beer);
Is there a long term move to have Drupal aggregate variables for modules so we can cope with a large number of new modules and large numbers of variables for some modules?
Would it reduce the database usage if we did put a bunch of variables in one variable? I have 10 or more variables in some modules and all the variables for all the modules are in one array because they are all loaded for every page. In effect I use $free['beer']['size_of_glass']
in one part of my code and $free['wine']['type_of_grape']
in another.
I know cache should reduce the usage but cache is turned off for logged in users and I am seeing Drupal sites where logged in users get far slower service when they should be getting faster service. If something keeps Drupal's flexibility and speeds up service then it is worth investigating.