Created
April 3, 2015 17:24
-
-
Save kirsn/27d50c2863cde0376022 to your computer and use it in GitHub Desktop.
Web2py cache usage / test script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
def print_rows(rows): | |
print time.ctime() | |
for row in rows: | |
print row | |
db = DAL('sqlite://cache_test.db', pool_size=0) | |
db.define_table('t1', Field('name',type='string')) | |
print "%s : Defining disk based cache, with 5 seconds timeout" % time.ctime() | |
cache_settings = dict(cache=(cache.disk, 5), cacheable=True) | |
for i in range(10): | |
record = "A%s" % i | |
print "Inserting record %s" % record | |
db.t1.insert(name=record) | |
time.sleep(2) | |
print_rows(db(db.t1.id > 0).select(**cache_settings)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment