diff options
author | Martin Jørgensen <hello@martinnj.dk> | 2021-06-17 19:59:49 +0200 |
---|---|---|
committer | Martin Jørgensen <hello@martinnj.dk> | 2021-07-13 07:32:50 +0200 |
commit | 75fe5c81c35d2bcfc8e6a697aef948efbfebe8ba (patch) | |
tree | b2adb7b10dd1db424d74c23ca09ad32fa958997a /docs | |
parent | 7e243214c71661018ede3b927d11ef9172f84c4e (diff) | |
download | pymemcache-75fe5c81c35d2bcfc8e6a697aef948efbfebe8ba.tar.gz |
Add RetryingClient. Fixes #307
Diffstat (limited to 'docs')
-rw-r--r-- | docs/getting_started.rst | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 1b96e7e..962735a 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -77,6 +77,34 @@ on if a server goes down. client.set('some_key', 'some value') result = client.get('some_key') +Using the built-in retrying mechanism +------------------------------------- +The library comes with retry mechanisms that can be used to wrap all kind of +pymemcache clients. The wrapper allow you to define the exceptions that you want +to handle with retries, which exceptions to exclude, how many attempts to make +and how long to wait between attemots. + +The ``RetryingClient`` wraps around any of the other included clients and will +have the same methods. For this example we're just using the base ``Client``. + +.. code-block:: python + + from pymemcache.client.base import Client + from pymemcache.client.retrying import RetryingClient + from pymemcache.exceptions import MemcacheUnexpectedCloseError + + base_client = Client(("localhost", 11211)) + client = RetryingClient( + base_client, + attempts=3, + retry_delay=0.01, + retry_for=[MemcacheUnexpectedCloseError] + ) + client.set('some_key', 'some value') + result = client.get('some_key') + +The above client will attempt each call three times with a wait of 10ms between +each attempt, as long as the exception is a ``MemcacheUnexpectedCloseError``. Using TLS --------- |