This is just a quick caveat (or reminder). If you delete a variable from the variables table, always clear the cached entry of the variables too. Drupal caches the whole variables table in the cache table in an entry called 'variables'.
Here are two cases (of the many) you'll need this.
When you're writing your own module and you're setting some variables, always clean them up. Fastest way is by issuing a direct query to the database.
* Implementation of hook_uninstall().
*/
function my_module_uninstall() {
db_query("DELETE FROM {variable} WHERE name LIKE 'my_module_%'");
cache_clear_all('variables', 'cache');
}
A second typical case I can come up with is when releasing the cron semaphore after it got 'stuck'.
DELETE FROM cache WHERE cid = 'variables';
Delicious
Digg