2
.ini文件金字塔烧杯缓存的问题 - 类型错误:int()函数的参数必须是字符串或数字,而不是 'NoneType'
cache.regions = default_term, second, short_term, long_term
cache.type = memcached
cache.url = 127.0.0.1:11211
cache.second.expire = 1
cache.short_term.expire = 60
cache.default_term.expire = 300
cache.long_term.expire = 3600
__init__.py
文件
from pyramid_beaker import set_cache_regions_from_settings
def main(global_config, **settings):
set_cache_regions_from_settings(settings)
...
test.py文件
from beaker.cache import CacheManager
from beaker.util import parse_cache_config_options
cache_opts = {
'cache.data_dir': '/tmp/cache/data',
'cache.lock_dir': '/tmp/cache/lock',
'cache.regions': 'short_term, long_term',
'cache.short_term.type': 'ext:memcached',
'cache.short_term.url': '127.0.0.1.11211',
'cache.short_term.expire': '3600',
'cache.long_term.type': 'file',
'cache.long_term.expire': '86400',
}
cache = CacheManager(**parse_cache_config_options(cache_opts))
@cache.region('short_term', 'test')
def test_method(*args, **kwargs):
在执行上面的代码时会给出错误:
...
File "c:\python27\lib\site-packages\python_memcached-1.48-py2.7.egg\memcache.py", line 1058, in __init__
self.port = int(hostData.get('port', 11211))
TypeError: int() argument must be a string or a number, not 'NoneType'
任何想法可能会导致错误/或我失去了什么?
看看'hostData [ '口']'。它似乎是'没有'......(我不知道为什么,我想我只是假设'hostData'是一个冠军...) – mgilson
你削减了你的追踪的一大部分;大概它来自你的测试? –