sinacloud / sae-python-dev-guide

SAE Python开发者手册
http://sae.sina.com.cn/doc/python
462 stars 353 forks source link

kv.get_by_prefix 不正常。 #56

Closed ccdjh closed 11 years ago

ccdjh commented 11 years ago

class T(tornado.web.RequestHandler): def get(self): kv = sae.kvdb.KVClient() c = kv.get_by_prefix('t') self.write(str(c))

返回结果是 :

《generator object _get_by_prefix at 0x14dc500》

chanfung032 commented 11 years ago

kv.get_by_prefix的返回值是一个generator,如果需要转换成list,可以这样:

[i for i in kv.get_by_prefix('t')]
ccdjh commented 11 years ago

getkeys_by_prefix 和 get_by_prefix 都出问题。你测试一下。

chanfung032 commented 11 years ago
>>> import sae.kvdb
>>> kv = sae.kvdb.KVClient()
>>> result = kv.get_by_prefix('k')
>>> [i for i in kv.get_by_prefix('k', limit=5)]
[('k', 123443), ('k0', '<value>'), ('k1', 1), ('k10', '<value>'), ('k100', '<value>')]

没有问题阿。

ccdjh commented 11 years ago

囧,因为之前kv.get_by_prefix('k')是直接返回一个完整的list的。是我的操作问题,还是你们改了?