diff options
| author | Roman <reclosedev@gmail.com> | 2012-04-11 21:39:28 +0400 |
|---|---|---|
| committer | Roman <reclosedev@gmail.com> | 2012-04-11 21:39:28 +0400 |
| commit | cb8845e8696533b1e8ebda8adbeaa436bba78809 (patch) | |
| tree | 2452ba39dc9948c1ba7bc8f8fbb56af7110f4d14 /docs/user_guide.rst | |
| parent | 8efee9a7986e853858d6f0f25475ef8e60f9a971 (diff) | |
| download | requests-cache-cb8845e8696533b1e8ebda8adbeaa436bba78809.tar.gz | |
Docs: small fixes
Diffstat (limited to 'docs/user_guide.rst')
| -rw-r--r-- | docs/user_guide.rst | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/docs/user_guide.rst b/docs/user_guide.rst index ab7370c..cd77d77 100644 --- a/docs/user_guide.rst +++ b/docs/user_guide.rst @@ -40,9 +40,10 @@ For example, following code will take only 1-2 seconds instead 10:: for i in range(10): requests.get('http://httpbin.org/delay/1') -Cache can be configured with some options, such as cache filename, backend (sqlite, memory), -expiration time, etc. E.g. cache stored in sqlite database (default) -named ``'test_cache.sqlite'`` with expiration set to 5 minutes can be configured as:: +Cache can be configured with some options, such as cache filename, backend +(sqlite, mongodb, memory), expiration time, etc. E.g. cache stored in sqlite +database (default format) named ``'test_cache.sqlite'`` with expiration +set to 5 minutes can be configured as:: request_cache.configure('test_cache', backend='sqlite', expire_after=5) @@ -54,8 +55,10 @@ named ``'test_cache.sqlite'`` with expiration set to 5 minutes can be configured Transparent caching is achieved by monkey-patching ``requests`` library (it can be disabled, see ``monkey_patch`` argument for :func:`configure`) , It is possible to undo this patch, and redo it again with :func:`undo_patch` and -:func:`redo_patch`. But preferable way is to use :func:`requests_cache.disabled() <requests_cache.core.disabled>` -and :func:`requests_cache.enabled <requests_cache.core.enabled>` context managers for temporary disabling and enabling caching:: +:func:`redo_patch`. But preferable way is to use +:func:`requests_cache.disabled() <requests_cache.core.disabled>` +and :func:`requests_cache.enabled <requests_cache.core.enabled>` +context managers for temporary disabling and enabling caching:: with requests_cache.disabled(): for i in range(3): @@ -65,7 +68,7 @@ and :func:`requests_cache.enabled <requests_cache.core.enabled>` context manager for i in range(10): print(requests.get('http://httpbin.org/delay/1').text) -Also you can check if url is present in cache with :func:`requests_cache.has_url() <requests_cache.core.has_url>` +Also, you can check if url is present in cache with :func:`requests_cache.has_url() <requests_cache.core.has_url>` and delete it with :func:`requests_cache.delete_url() <requests_cache.core.delete_url>` :: @@ -79,6 +82,9 @@ and delete it with :func:`requests_cache.delete_url() <requests_cache.core.delet >>> requests_cache.has_ulr('http://httpbin.org/get') False +.. seealso:: `example.py <https://bitbucket.org/reclosedev/requests-cache/src/tip/example.py>`_ + + Persistence ----------- @@ -91,15 +97,14 @@ List of available backends: - ``'memory'`` - not persistent, stores all data in Python ``dict`` in memory - ``'mongodb'`` - (**experimental**) MongoDB database (``pymongo`` required) - .. note:: ``pymongo`` doesn't work fine with `gevent <http://www.gevent.org/>`_ which powers ``requests.async``. - But there is some workarounds, see question on + .. note:: ``pymongo`` doesn't work fine with `gevent <http://www.gevent.org/>`_ which powers ``requests.async``, + but there is some workarounds, see question on `StackOverflow <http://stackoverflow.com/questions/7166998/pymongo-gevent-throw-me-a-banana-and-just-monkey-patch>`_. Also, you can write your own. See :ref:`cache_backends` API documentation and sources. ---------------------- -For more information see :doc:`API reference <api>` and example_. +For more information see :doc:`API reference <api>` . -.. _example: https://bitbucket.org/reclosedev/requests-cache/src/tip/example.py |
