A client for falling back to older memcached servers when performing reads.
It is sometimes necessary to deploy memcached on new servers, or with a different configuration. In these cases, it is undesirable to start up an empty memcached server and point traffic to it, since the cache will be cold, and the backing store will have a large increase in traffic.
This class attempts to solve that problem by providing an interface identical to the Client interface, but which can fall back to older memcached servers when reads to the primary server fail. The approach for upgrading memcached servers or configuration then becomes:
Deploy a new host (or fleet) with memcached, possibly with a new configuration.
From your application servers, use FallbackClient to write and read from the new cluster, and to read from the old cluster when there is a miss in the new cluster.
Wait until the new cache is warm enough to support the load.
Switch from FallbackClient to a regular Client library for doing all reads and writes to the new cluster.
Take down the old cluster.
Make sure that the old client has “ignore_exc” set to True, so that it treats failures like cache misses. That will allow you to take down the old cluster before you switch away from FallbackClient.
- class pymemcache.fallback.FallbackClient(caches)
- add(key, value, expire=0, noreply=True)
- append(key, value, expire=0, noreply=True)
- cas(key, value, cas, expire=0, noreply=True)
Close each of the memcached clients
- decr(key, value, noreply=True)
- delete(key, noreply=True)
- flush_all(delay=0, noreply=True)
- incr(key, value, noreply=True)
- prepend(key, value, expire=0, noreply=True)
- replace(key, value, expire=0, noreply=True)
- set(key, value, expire=0, noreply=True)
- touch(key, expire=0, noreply=True)