So help me out here...
I have this code:
def saveAddress():
#session.forget(response)
houses = None
useCached = True
if request.post_vars.address:
useCached = False
newhouse = db.house.insert(address=request.post_vars.address,person
=request.post_vars.owner)
houses = db(db.house.person == request.post_vars.owner).select(
db.house.ALL,cache=(cache.ram, 0))
if houses == None:
houses = db(db.house.person == request.post_vars.owner).select(
db.house.ALL,cache=(cache.ram, 600))
return dict(houses=houses)
It looks like it works... The idea being that when I insert a new item into
the house table, I want to expire the cache. I thought I could do that with
"cache=(cache.ram, 0)".
When I say it looks like it works, I mean that I run the code, and when I
save, the new houses added show up, and when I refresh the page, all the
houses appear... but, is it really caching in this case? Note that I
removed the line for session.forget. I do this because I know when to
expire the cache. I can cache indefinitely. I'm the only one adding
records, and since that's the case, I can expire the cache just as soon as
a new record is added or updated. I'd ideally like to have a never expiring
cache.
On Friday, March 22, 2013 7:54:07 AM UTC-7, villas wrote:
>
> Niphlod and Anthony,
> Thanks so much for your comments which have assisted me both to understand
> and get it working.
>
> It seems that I missed the following paragraph in the book:
>
> time_expire = None
> Forces retrieval of the cached value, regardless of the time elapsed since
> it was saved (if time_expire is always None, the cached
> item will effectively never expire)
>
> Best wishes, D
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.