Try replace cache with cache2 = lambda key, f, expiration: cache.get(key,f, expiration) cache_db = (cache2, cache_time_expire)
On Friday, 14 June 2019 03:32:53 UTC-7, 黄祥 wrote: > > cache on select not work, modify apps/todo/api, cacheable=True is work > without defining cache > *apps/todo/__init__.py* > @action('api') # a GET API function > @action.uses(db) # all before starting a db connection > def todo(): > cache_time_expire = 10 > cache_db = (cache, cache_time_expire) > return dict(items=db(db.todo).select(orderby=~db.todo.id, cache= > cache_db, cacheable=True).as_list()) > > ERROR:root:Traceback (most recent call last): > File "/Users/sugizo/learn/python/web3py/web3py/core.py", line 413, in > wrapper > ret = func(*func_args, **func_kwargs) > File "/Users/sugizo/learn/python/web3py/web3py/core.py", line 379, in > wrapper > ret = func(*args, **kwargs) > File "/Users/sugizo/learn/python/web3py/apps/todo/__init__.py", line 31, > in todo > return dict(items=db(db.todo).select(orderby=~db.todo.id, cache= > cache_db, cacheable=True).as_list()) > File > "/Users/sugizo/miniconda3/envs/python3_todo/lib/python3.7/site-packages/pydal/objects.py" > , line 2395, in select > return adapter.select(self.query, fields, attributes) > File > "/Users/sugizo/miniconda3/envs/python3_todo/lib/python3.7/site-packages/pydal/adapters/sqlite.py" > , line 82, in select > return super(SQLite, self).select(query, fields, attributes) > File > "/Users/sugizo/miniconda3/envs/python3_todo/lib/python3.7/site-packages/pydal/adapters/base.py" > , line 762, in select > cache, sql, fields, attributes, colnames) > File > "/Users/sugizo/miniconda3/envs/python3_todo/lib/python3.7/site-packages/pydal/adapters/base.py" > , line 753, in _cached_select > time_expire) > TypeError: 'Cache' object is not callable > > *apps/todo/__init__.py* > @action('api') # a GET API function > @action.uses(db) # all before starting a db connection > def todo(): > cache_time_expire = 10 > cache_db = (cache.memoize(expiration=5), cache_time_expire) > return dict(items=db(db.todo).select(orderby=~db.todo.id, cache= > cache_db, cacheable=True).as_list()) > > ERROR:root:Traceback (most recent call last): > File "/Users/sugizo/learn/python/web3py/web3py/core.py", line 413, in > wrapper > ret = func(*func_args, **func_kwargs) > File "/Users/sugizo/learn/python/web3py/web3py/core.py", line 379, in > wrapper > ret = func(*args, **kwargs) > File "/Users/sugizo/learn/python/web3py/apps/todo/__init__.py", line 31, > in todo > return dict(items=db(db.todo).select(orderby=~db.todo.id, cache= > cache_db, cacheable=True).as_list()) > File > "/Users/sugizo/miniconda3/envs/python3_todo/lib/python3.7/site-packages/pydal/objects.py" > , line 2395, in select > return adapter.select(self.query, fields, attributes) > File > "/Users/sugizo/miniconda3/envs/python3_todo/lib/python3.7/site-packages/pydal/adapters/sqlite.py" > , line 82, in select > return super(SQLite, self).select(query, fields, attributes) > File > "/Users/sugizo/miniconda3/envs/python3_todo/lib/python3.7/site-packages/pydal/adapters/base.py" > , line 762, in select > cache, sql, fields, attributes, colnames) > File > "/Users/sugizo/miniconda3/envs/python3_todo/lib/python3.7/site-packages/pydal/adapters/base.py" > , line 753, in _cached_select > time_expire) > TypeError: decorator() takes 1 positional argument but 3 were given > > 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. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/161d0f94-8d18-46a5-9445-0cb072dd42c2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.