summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMartin Jørgensen <hello@martinnj.dk>2021-06-17 19:59:49 +0200
committerMartin Jørgensen <hello@martinnj.dk>2021-07-13 07:32:50 +0200
commit75fe5c81c35d2bcfc8e6a697aef948efbfebe8ba (patch)
treeb2adb7b10dd1db424d74c23ca09ad32fa958997a /docs
parent7e243214c71661018ede3b927d11ef9172f84c4e (diff)
downloadpymemcache-75fe5c81c35d2bcfc8e6a697aef948efbfebe8ba.tar.gz
Add RetryingClient. Fixes #307
Diffstat (limited to 'docs')
-rw-r--r--docs/getting_started.rst28
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
---------