I like the flexibility of the beaker cache, but am having trouble
accomplishing exactly what I want.  I understand that if I use the
@cache.cache or @cache.region decorators, I automatically get caching
based on the function arguments.  That's fantastic!  But, the one area
it's getting me into trouble is the situation where I need to
invalidate all cache entries matching only a subset of the function
arguments.

Here's a short example of what I mean.  Assume the following
controller function that gets widgets from the database based on their
color and size:

def widgets(self, color, size):

    @cache.region('short_term')
    def get_widgets(color, size):
        # query the database
        return widgets

Suppose this cache is built up with all the widgets in the database.
Now, I add a blue widget, so I'd like to invalidate the cache for the
get_widgets() function for *all* blue widgets.  It seems to me that
I'd have to repeatedly call invalidate_region(), enumerating all
possible widget sizes, e.g.:

invalidate_region(get_widgets, 'short_term', 'blue', 'small')
invalidate_region(get_widgets, 'short_term', 'blue', 'medium')

etc.  Is this what I'd have to do?  Because when the arguments aren't
so discrete, this would be a big problem.  Is there some easier way to
tell beaker to invalidate *all* entries that match a specific argument
(or combination of arguments)?  And, if not, does anyone think this
would be a good inclusion for a future version of beaker?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to