根据 sqlalchemy 文档提供的缓存 sqlalchemy 查询的示例,我们应该这样做
from caching_query import FromCache
# load Person objects. cache the result under the namespace "all_people".
print "loading people...."
people = Session.query(Person).options(FromCache("default", "all_people")).all()
我在 development.ini 中有以下烧杯配置
cache.regions = day, hour, minute, second
cache.type = file
cache.data_dir = %(here)s/cache/sess/data
cache.lock_dir = %(here)s/cache/sess/lock
cache.second.expire = 1
cache.minute.expire = 60
cache.hour.expire = 3600
cache.day.expire = 86400
当我在我的应用程序中使用上面的示例代码时,数据没有缓存在缓存文件夹中,所以我假设基于内存的缓存是默认设置,是否可以将 sqlalchemy 缓存类型切换为基于文件的缓存?还是我弄错了?