Done : Issue 655 http://code.google.com/p/web2py/issues/detail?id=655:Adding
cache argument to .count()
Richard
On Fri, Feb 10, 2012 at 12:02 AM, Massimo Di Pierro
massimo.dipie...@gmail.com wrote:
open a ticket. this should be added
On Feb 9, 11:42 am, Richard Vézina
The two methods you described are the only available methods to achieve
such a thing.
If you have 100 records returned and you want to paginate by 20 (5 pages),
then the difference between one method or the other is negligible.
If you have 1000 records returned and you want to paginate by 20
Would another option be to cache the entire select and pull out the needed
records based on the page requested:
records = db(db.pages.active==True).select(cache=(cache.ram, 300))
I suppose that wouldn't be a good idea if there are likely to be enough
records and/or enough simultaneous users
I can think of two ways to do it, but I don't like either one. First
is to formulate the query without the limitby clause and do a
db(query).count(). That would give me the total number of records in
the set. Then add the limitby clause to the query to get the records
of interest.
Is it just me ?
db(query).count(cache=(cache.ram, 60))
Won't work...
I get :
TypeError: count() got an unexpected keyword argument 'cache'
Richard
On Thu, Feb 9, 2012 at 9:44 AM, Anthony abasta...@gmail.com wrote:
I can think of two ways to do it, but I don't like either one. First
is to
Under web2py 1.99.4
Richard
On Thu, Feb 9, 2012 at 12:42 PM, Richard Vézina ml.richard.vez...@gmail.com
wrote:
Is it just me ?
db(query).count(cache=(cache.ram, 60))
Won't work...
I get :
TypeError: count() got an unexpected keyword argument 'cache'
Richard
On Thu, Feb 9, 2012 at
I don't think a count can be cached that way, but since it just returns a
number, it can be cached in the usual way instead:
count = cache.ram('count', lambda: db(query).count(), time_expire=60)
Anthony
On Thursday, February 9, 2012 12:42:02 PM UTC-5, Richard wrote:
Is it just me ?
I just check gluon/dal.py and if it is the count() code location it's not
have cache argument... Also I notice that there seems to have many
differents implementations of count... I wouder why it could not be a
generic function reused everywhere, it would be more DRY...
Richard
On Thu, Feb 9,
open a ticket. this should be added
On Feb 9, 11:42 am, Richard Vézina ml.richard.vez...@gmail.com
wrote:
Is it just me ?
db(query).count(cache=(cache.ram, 60))
Won't work...
I get :
TypeError: count() got an unexpected keyword argument 'cache'
Richard
On Thu, Feb 9, 2012 at
Thanks Richard.
Not heavy use sites as they are business to business or management
tool sites.
On Feb 8, 5:31 pm, Richard Vézina ml.richard.vez...@gmail.com wrote:
If your query don't involve joins, why not making to request to database?
If you don't have a heavy load site I don't think you
10 matches
Mail list logo