python-memcache 不加载/存储任何内容

标签 python caching memcached

所以我尝试了memcache。在我的 Ubuntu 上执行“apt-get install python-memcache”,然后:

>>> import memcache
>>> s = memcache.Client(["127.0.0.1:11211"])
>>> s.set("mykey", "myvalue")
0
>>> myvar = s.get("mykey")
>>> print(myvar)
None

出了什么问题?

最佳答案

您没有运行 memcached 服务。以下是服务启动后的样子:

>>> s = memcache.Client(["127.0.0.1:11211"])
>>> s.set("mykey", "myvalue")
True
>>> myvar = s.get("mykey")
>>> print(myvar)
myvalue

以下是检查它是否正在运行的方法:

$ service memcached status
 * memcached is running

关于python-memcache 不加载/存储任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18763098/

相关文章:

python - Python ctypes 字段中的回调函数

Visual Studio Code 中的 Python 重构失败

python - 文本处理 - Python 与 Perl 的性能对比

python - 识别时间序列何时通过图表和表格中的阈值

caching - 数据在处理之前是否从 RAM 通过缓存(L3、L2、L1)?

linux - 在 Linux 上刷新数据缓存

php - 页面浏览量计数器在第一次页面调用时增加 +3(有时 +2),然后 +1,为什么?

javascript - 使用具有未定义的成功回调函数的 Bluebird

caching - memcached 中的数据应该有多细粒度?