I think he mean :

var_name = cache.ram('var_name',  lambda: do_something, time_expire=3600)

You can then clear the cache like this :

cache.ram.clear(var_name)

Richard

On Thu, Sep 27, 2012 at 1:27 PM, MichaelF <mjfs...@gmail.com> wrote:

> By 'cache' do you mean a session variable (or several)? Wouldn't that work?
>
>
> On Thursday, September 27, 2012 8:00:59 AM UTC-6, Anthony wrote:
>>
>> I suppose it depends on whether all the calculations and db accesses are
>> needed for the processing as well as the initial creation. If not, you
>> could do something like:
>>
>> if not request.post_vars:
>>     form = a_lot_of_calculations_and_db_**accesses()
>> else:
>>     form = minimal_form_without_all_the_**calculations()
>>
>> Another option is to cache some of the results of the calculations as
>> well as the db queries. You could clear the cache whenever the form is
>> created (i.e., when there are no request.post_vars) but pull from the cache
>> when the form is submitted.
>>
>> Anthony
>>
>> On Thursday, September 27, 2012 1:05:43 AM UTC-4, mweissen wrote:
>>>
>>> I have a fundamental question. Let's say I have a function like
>>>
>>> def mypage():
>>>     form = a_lot_of_calculations_and_db_**accesses()
>>>     if form.process().accepted:
>>>         do_something()
>>>     return dict(form=form)
>>>
>>> The part a_lot_of_calculations_and_db_**accesses() runs twice: first
>>> time to prepare the page and a second time to handle the responses. Is
>>> there any way to avoid these double call of
>>> a_lot_of_calculations_and_db_**accesses()?
>>>
>>> Regards, Martin
>>>
>>>
>>  --
>
>
>
>

-- 



Reply via email to