def select(self, query, fields, attributes):
"""
Always returns a Rows object, possibly empty.
"""
sql = self._select(query, fields, attributes)
cache = attributes.get('cache', None)
if cache and attributes.get('cacheable', False):
del attributes['cache']
(cache_model, time_expire) = cache
key = self.uri + '/' + sql
if len(key) > 200: key = hashlib_md5(key).hexdigest()
args = (sql, fields, attributes)
return cache_model(
key,
lambda self=self, args=args: self._select_aux(*args),
time_expire)
else:
return self._select_aux(sql, fields, attributes)
评论列表
文章目录