Closed (fixed)
Project:
Chaos Tool Suite (ctools)
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
26 Jul 2009 at 21:46 UTC
Updated:
22 Oct 2009 at 14:20 UTC
Jump to comment: Most recent file
Comments
Comment #1
alex_b commentedComment #2
sdboyer commentedDefinitely useful, but it needs to be more granular. Resetting the entire cache, including tables that you're not concerned with, is probably wasteful, and potentially even damaging to other modules using the object cache. Would you mind rerolling with a more complicated $reset parameter that allows either a) a full reset of the cache or b) selective resets? Off the top of my head, it seems like using a simple array with the names of the caches to be reset ought to be sufficient.
Comment #3
aron novakIt's much more fine-grained now.
Comment #4
sdboyer commentedStill not quite what I'm looking for. Really doing this properly may well entail a separate function where the static caches are contained that has more get/set style parameters. That way we can separate the granular cache clearing from the loader itself.
Meh, I may just write this myself real quick.
Comment #5
aron novakIs this function signature something that you'd like to see?
In ctools_export_load_object(), i'd eliminate the two static variables and encapsulates the functionality in one function.
If you like this direction, i can post a patch, otherwise, if you give me more detailed instructions, i happily implement that direction as well.
Comment #6
sdboyer commented/me smiles
Yup, that's exactly the kind of thing I had in mind. I just ran out of time. Roll me a patch with that sort of function signature, and I'll put it right in.
Comment #7
aron novakHere is the patch.
Comment #8
alex_b commentedThe approach in #7 is very specific to ctools_export_load_object(). Further, there are some problems (return FALSE in a function that returns by reference, not sure whether the correct static cache (there are 2) is always returned.
I refactored with http://api.drupal.org/api/function/drupal_static/7 in mind. ctools_static() and ctools_static_reset() are backports of Drupal 7's drupal_static() and drupal_static_reset(). ctools_export_load_object() uses these functions.
While this definitely helps the problem I initially described in this issue, I am not 100 % happy with moving resetting from a flag in the function signature of ctools_export_load_object() to an external static cache because it means that implementing modules will have assumptions about ctools_export_load_object()'s guts.
Using ctools_static() AND a reset flag in ctools_export_load_object() would be my preferred way: ctools_static() makes sense because it opens the possibility to do a global reset with ctools_static_reset(NULL) while the internal static caches in ctools_export_load_object() stay encapsulated.
Comment #9
sdboyer commentedI'll have a look at this and respond in detail tomorrow. Thanks!
Comment #10
alex_b commentedThought more about this.
Instead of a $reset flag, we should use a separate function to reset internal static caches.
This patch...
- adds ctools_static() and ctools_static_reset() modeled after drupal_static() as in #8
- makes ctools_export_load_object() use ctools_static() as in #8
- adds ctools_export_load_object_reset() to reset internal caches in ctools_export_load_object()
Comment #11
alex_b commentedUm, yeah: patch for #10
Comment #12
merlinofchaos commentedIs this modelled after the static system that's in D7? (I ask because I'm not familiar enough with it to just look at the code and see).
Comment #13
alex_b commented#12: it is. See links in #8. #8 starts a different approach from the patches above.
Comment #14
sdboyer commentedI'm happy. Almost completely happy.
Only problem is that we're still just globally clearing the export cache. Give me some changes to
ctools_export_load_object_reset(), or a separate function for granular cache resets, and I'll commit.Comment #15
alex_b commentedGreat. Function signature is now
Comment #16
alex_b commentedSame patch for DRUPAL 7.
Comment #17
merlinofchaos commentedI like this! Committed to both branches.
Comment #18
alex_b commentedAwesome!