there is not much really 
.... 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Caching-selects
 
to see how to cache (it's not that different from the usual cache in 
web2py).

instead of db(db.table.id>0).select() you use 
db(db.table.id>0).select(cache=(cache.ram, 60)) if you can leave with the 
same data for 60 seconds without hitting the database. Moreover, if you use 
db(db.table.id>0).select(cache=(cache.ram, 60), cacheable=True) it'll be 
faster but your code can't use row.update_record() and row.delete_record().

 If you want to use redis ... install it on the server,. than 
http://web2py.com/books/default/chapter/29/13/deployment-recipes#Caching-with-Redis
 
. Instead of using cache.ram you use cache.redis. same API interface, 
handled transparently.
Bonus point if you want to auto-fix the "thundering herd" problem (many 
users requesting a the same time something that isn't in cache): use 
with_lock=True and it'll be fetched one time only, while other wait in line 
the result calculated by the first client requesting the data.


On Thursday, June 11, 2015 at 2:58:47 PM UTC+2, Fabiano Faver wrote:
>
> Niphlod, I have a small app the DB is getting big quickly and was asked to 
> do a cache layer..I just started started to learn about it and i'm already 
> lost.  Could you point the direction to a newbie how to do it? Is it just 
> some code change in web2py? I saw there is this Redis but didn't read yet 
> how it works together with web2py and if it is this the way to do this 
> cache layer.
>
>
>
> Em quarta-feira, 24 de dezembro de 2014 16:10:15 UTC-2, Niphlod escreveu:
>>
>> so, what's the issue you're facing ?
>>
>> On Wednesday, December 24, 2014 12:29:24 PM UTC+1, harsha tanguturi wrote:
>>>
>>> I would like to cache the model data i.e., caching the selects and 
>>> update the cache whenever the data is updated. Putting simply a caching 
>>> layer has to present before the database layer and any changes to the 
>>> database should be reflected in cache too.
>>>
>>

-- 
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.

Reply via email to