python包pymemcache的扩展,通过pymemcache.json提供客户端配置。
pymemcache-client的Python项目详细描述
pymemcache客户端
提供客户端配置的python包pymemcache的扩展。
安装
pip install pymemcache-client
安装memcached
要在“localhost”上本地运行示例和测试,必须安装memcached。
使用brew安装memcached
start memcached使用brew
$ brew install memcached==> Installing memcached==> Downloading https://homebrew.bintray.com/bottles/memcached-1.5.3.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring memcached-1.5.3.sierra.bottle.tar.gz
==> Caveats
To have launchd start memcached now and restart at login:
brew services start memcached
Or, if you don't want/need a background service you can just run:
/usr/local/opt/memcached/bin/memcached
==> Summary
? /usr/local/Cellar/memcached/1.5.3: 11 files, 198.7KB
$ brew services start memcached==> Successfully started `memcached`(label: homebrew.mxcl.memcached)
架构
python包的扩展名pymemcache返回from pymemcache.client.hash import HashClient 并使用~/.pymemcache.json或pymemcache.json进行配置。
功能性
class PymemcacheClient:使用可用配置准备pymemcache客户端。
创建此类实例时,可以通过以下方式提供配置:
- 用户级文件:~/.pymemcache.json
- 应用程序级文件:./pymemcache.json
- 以json格式的file path值提供给参数config_file
- 以json格式的dict值提供给参数config
配置
这是可以以json格式提供给class PymemcacheClient的预期配置:
{ "client_type": "[OPTIONAL str, DEFAULT 'basic']", "servers": [ { "host": "[str]", "port": [int] } ], "server_type": "[OPTIONAL str, DEFAULT 'standard']", "connect_timeout": [OPTIONAL float, Defaults to forever], "timeout": [OPTIONAL float, Defaults to forever], "no_delay": [OPTIONAL bool, DEFAULT false], "ignore_exc": [OPTIONAL bool, DEFAULT false], "default_noreply": [OPTIONAL bool, DEFAULT true], "allow_unicode_keys": [OPTIONAL bool, DEFAULT false] }
- "client_type":[可选]memcached客户端的类型,默认值"basic"
- "basic":使用from pymemcache.client.base import Client的memcached客户端。单个memcached服务器的客户端。
- "hash":使用from pymemcache.client.hash import HashClient的memcached客户端。用于与memcached服务器群集通信的客户端。
- "servers":memcached服务器列表,至少需要一个。
- 如果"client_type"是"basic",则需要1个服务器,只需要1个。
- 如果"client_type"是"hash",则需要一个或多个服务器。
- "server_type":定义连接到memcached服务器的特殊需要,默认值为"standard"。
- "standard":使用标准http共享服务器连接。
- "elasticache":通过AWS Elasticache使用自动发现共用服务器连接。
- "connect_timeout":可选浮点,等待连接到memcached服务器的秒数。默认为“永远”(使用底层默认套接字超时,可能很长),即套接字处于阻塞模式,等待连接到memcached服务器。
- "timeout":可选浮点,可选浮点,在连接到memcached的套接字上等待发送或接收调用的秒数。默认为“永远”(使用底层默认套接字超时,可能很长),即套接字处于阻塞模式。
- "no_delay":可选bool,设置tcpunodelay标志,这在某些情况下可能有助于提高性能。默认值false。
- "ignore_exc":可选bool,如果为true,则会导致“get”、“gets”、“getu many”和“gets many”调用将任何错误视为缓存未命中。默认值false。
- "default_noreply":可选bool,传递给存储命令的'noreply'的默认值。默认值true。
- "allow_unicode_keys":可选bool,支持unicode(utf8)键。默认值false。
0.3.2(2018-02-16)
- 迁移到github/tunelab
0.3.1(2018-01-25)
- 迁移到github/tuneinc
0.3.0(2017-12-10)
- 阅读docs.org
0.2.0(2016-12-08)
- α
- 更健壮的json配置
- 句柄pymemcache.client.hash.HashClient
- 句柄pymemcache.client.base.Client
0.1.0(2016-12-07)
- 首次发布
0.0.1(2016-12-07)
- 初始提交