[Myghty-users] Caching a part of a module component
Brought to you by:
zzzeek
From: Ben B. <bba...@am...> - 2005-02-18 02:09:29
|
I have a module component which does some rather CPU and database intensive queries, it then passes the results of those queries onto its original request. So the process sorta looks like this: ** Do heavy CPU / Database operations ** ** Pass objects into component call, save output ** ** Pass output of component into m.subexec ** How do I cache the first two parts, so that rather than doing the database/comp call, I just check for the cached comp, and pass its value directly into the subexec? I currently am doing something like this with no luck: cache = m.cache(component='/dynamic_directory_content.myt') if not cache.has_key('diroutput'): del cache # WHOLE BUNCH OF DATABASE STUFF HERE directoryContent = m.scomp('/dynamic_directory_content.myt', OBJECTS, **params) m.subexec(path, directory_content = directoryContent, **params) else: dirContent = cache.get_value('diroutput') m.subexec(path, directory_content = dirContent, **params) I have a m.cache_self inside dynamic_directory_content, setting the key 'diroutput'. The error it gives is: Myghty Template Error Error: Error: 'diroutput' File: /path/components/dynamic_directory_content.myt line 347 Context: 344: aggregateTotals 345: </%args> 346: <%init> 347: m.cache_self(key='diroutput',expire_time=600) 348: from datetime import date 349: </%init> 350: Or is there a better approach to caching a chunk of a module component? Thanks, Ben |