def _select_aux(self, sql, fields, attributes):
args_get = attributes.get
cache = args_get('cache',None)
if not cache:
self.execute(sql)
rows = self._fetchall()
else:
if isinstance(cache, dict):
cache_model = cache['model']
time_expire = cache['expiration']
key = cache.get('key')
if not key:
key = self.uri + '/' + sql + '/rows'
key = hashlib_md5(key).hexdigest()
else:
(cache_model, time_expire) = cache
key = self.uri + '/' + sql + '/rows'
key = hashlib_md5(key).hexdigest()
def _select_aux2():
self.execute(sql)
return self._fetchall()
rows = cache_model(key,_select_aux2,time_expire)
if isinstance(rows,tuple):
rows = list(rows)
limitby = args_get('limitby', None) or (0,)
rows = self.rowslice(rows,limitby[0],None)
processor = args_get('processor', self.parse)
cacheable = args_get('cacheable',False)
return processor(rows,fields,self._colnames,cacheable=cacheable)
评论列表
文章目录