我正在尝试更改最大密钥长度 我尝试了以下示例:
from twisted.internet import reactor, protocol
from twisted.protocols.memcache import MemCacheProtocol, DEFAULT_PORT
import string
from twisted.python import log
import sys
log.startLogging(sys.stdout)
def cb(response):
log.msg(response)
d = protocol.ClientCreator(reactor, MemCacheProtocol
).connectTCP('localhost', DEFAULT_PORT)
def doSomething(proto):
# Here you call the memcache operations
return proto.set(string.ascii_letters*5, string.ascii_letters*5)
MemCacheProtocol.MAX_KEY_LENGTH = 1000
d.addCallback(doSomething)
d.addBoth(cb)
d.addBoth(lambda ignore: reactor.stop())
reactor.run()
我总是失败:
[Failure instance: Traceback (failure with no frames): <class 'twisted.protocols.memcache.ClientError'>: bad command line format!
我猜并不是所有的消息都被发送到memcache服务器,结果它返回这个失败 要在memcache中存储长度大于250的密钥,我需要做什么?你知道吗
你修改它太晚了。试试这个:
现在在ClientCreator()调用中使用这个类,而不是原来的类。你知道吗
相关问题 更多 >
编程相关推荐