Please sign in to comment.
Support weights for servers
In the previous implementation, although it supports ketama_weighted distribution, there is no way to provide server weights when declaring the server list. The only way to get weighted servers is to use the libmemcached memcache_servers_parse() function, which allows a format string of "<addr>:<port>:<weight>". However, pylibmc will not accept that format. Instead, given the simple and similar API exposed by libmemcached, it's very easy to add an optional weight to the server list tuple, and the default weight (0) is handled automatically by libmemcached. Example:: client = pylibmc.Client(servers=[(_pylibmc.server_type_tcp, '127.0.0.1', 11211, 4), (_pylibmc.server_type_tcp, '127.0.0.1', 11212), '127.0.0.1:11213:2']) # client.addresses now contains 3 servers (all localhost, ports # 11211-11213), with weights of 4, 1, and 2, respectively. Change-Id: I2cd6b93aca9b9bec22d3cd2a2e95d7ee3bdb38b3
- Loading branch information...
Showing with 47 additions and 23 deletions.