here is the code i used to learn cache *models/db0.py* # -*- coding: utf-8 -*- db.define_table('test_0', Field('name'), format = lambda r: '%s' % (r.name) )
db.define_table('test_1', Field('test_0', 'reference test_0'), Field('name'), format = lambda r: '%s' % (r.name) ) *controllers/test.py* # -*- coding: utf-8 -*- auth.requires_login()(lambda: None)() cache.action(time_expire = 300, cache_model = cache.ram, quick = 'SVLUP')(lambda: None)() #cache(request.env.path_info, time_expire = 300, cache_model = cache.ram)(lambda: None)() def master_test_1(): grid = SQLFORM.grid(db.test_1) return locals() def transaction_test_1(): redirect_url = 'report_form_test_1' form = SQLFORM.factory( Field("name", requires = IS_NOT_EMPTY() ), Field("test_0", "reference test_0", requires = IS_IN_DB(db, 'test_0.id', db.test_0._format, cache = (cache.ram, 3600) ) ) ) if form.process().accepted: name = form.vars.name test_0 = form.vars.test_0 db.test_1.insert(name = name, test_0 = test_0) redirect(URL(redirect_url) ) elif form.errors: response.flash = T('Form has errors') return dict(form = form) def report_form_test_1(): redirect_url = 'report_test_1' form = SQLFORM.factory( Field("test_0", "reference test_0", requires = IS_IN_DB(db, 'test_0.id', db.test_0._format, cache = (cache.ram, 3600) ) ) ) if form.process().accepted: test_0 = form.vars.test_0 #response.new_window = URL(redirect_url, args = test_0) redirect(URL(redirect_url, args = test_0) ) elif form.errors: response.flash = T('Form has errors') return dict(form = form) def report_test_1(): test_0 = request.args(0) query = (db.test_1.test_0 == test_0) rows = db(query).iterselect(cache = (cache.ram, 3600), cacheable = True) view_report_test_1 = dict(rows = rows) return response.render(view_report_test_1) #return view_report_test_1 *in the book said :* Use cache.ram as much as you can but make sure to use a finite set of keys, or else the amount of cache used will grow arbitrarily. *so my question is :* 1 the cache automatically clear after the expire time met or not? if not, so we must cleared it manually by using cache.ram.clear() or cache.disk.clear(), so that the size of cache didn't grow isn't it? 2 why in admin page clean function didn't clear the cache, it's just clean the errors and sessions but the response flash tell cache, sessions and errors cleared? thanks and best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.