cache_disk = CacheOnDisk(folder='path...')
cache_ram = CacheInRam()
def write_query_to_db
(cache_url, data):
return cache_ram(cache_url, lambda: cache_disk(cache_url, lambda: data, 3600), 60)
# Return None if the key is not present
def read_query_from_db(cache_url):
# How do I read from the cache, the following doesn't seem to work
return cache_ram(cache_url, lambda: cache_disk(cache_url))
amazon = bottlenose.Amazon(CacheWriter=write_query_to_db,
CacheReader=read_query_from_db, ...)
def reader(cache_url):
return cache.ram(cache_url, lambda: None, time_expire=None) # Time expire can be any value you want here (e.g 3600 so bottlenose writes it again in an hour)
def writer(cache_url, response_text):
cache.ram(cache_url, lambda: response_text, time_expire=0) # Time expire needs to be 0 here to make sure it always writes
amazon = bottlenose.Amazon(CacheWriter=writer,
CacheReader=reader, ....)
________________________________________ Kiran Subbaraman http://subbaraman.wordpress.com/about/
--
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+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.