summaryrefslogtreecommitdiff
path: root/requests_cache/backends/base.py
Commit message (Collapse)AuthorAgeFilesLines
* Move storage class __str__ methods to base class, and just show keys instead ↵Jordan Cook2021-04-221-0/+3
| | | | of items
* Allow passing any valid backend connection kwargs via BaseCacheJordan Cook2021-04-191-8/+3
| | | | | | | | * Pass `**kwargs` to backend storage classes, split out any that are valid for the backend-specific connection function/class, and pass them to the connection * Add intersphinx links to docs for dependencies * Update and format some more backend class docstrings * Remove 'Unrecognized keyword arguments' warning from `BaseStorage` * Turn `warnings.warn` about using secret keys into a `logging.warning` (due to complaints about too many messages)
* Add option to manually cache response objectsJordan Cook2021-04-191-1/+2
| | | | Updates #98
* Don't show warnings for 'include_get_headers' and 'ignored_parameters' ↵Jordan Cook2021-04-181-7/+16
| | | | | | | kwargs in BaseStorage Also don't name them as private members, since they can safely by changed after initialization (e.g., `session.cache.include_get_headers = True`)
* Demote most logging.info statements to debugJordan Cook2021-04-101-2/+2
|
* Handle errors due to invalid responses in `BaseCache.urls`Jordan Cook2021-04-101-14/+18
|
* Add remove_old_entries() back to BaseCache as an alias with a DeprecationWarningJordan Cook2021-04-101-0/+5
|
* Improvements to Sphinx documentation:Jordan Cook2021-04-031-2/+1
| | | | | | | | | | | | | | * Use sphinx-apidoc to auto-generate sources for backend modules * Still manually adding other modules for more control over formatting * Add a couple more contributors I missed * Include contributors on readthedocs * Add 'all' Makefile target and clean auto-generated docs * Remove unused build targets in Makefile * Update interpshinx links that have moved * Fix some interpshinx links * Fix some `:ref:` links using auto-generated labels (and some manually added labels where convenient) * Fix some docstring formatting * Fix remaining build warnings
* Add 'verify' param to cache keyJordan Cook2021-04-011-2/+2
| | | | Closes #209
* Rename 'add_key_mapping' to 'save_redirect' and take a request instead of a ↵Jordan Cook2021-03-311-6/+7
| | | | cache key
* Fix BaseCache.urls to return only response URLs (no redirect keys)Jordan Cook2021-03-301-1/+1
|
* Move cache key utilities to a separate moduleJordan Cook2021-03-301-101/+10
|
* Add normalization for request jsonJordan Cook2021-03-301-4/+29
|
* Use url-normalize for additional URL normalization for cache keysJordan Cook2021-03-301-2/+6
|
* Also remove invalid responses when running remove_expired_responses()Jordan Cook2021-03-301-13/+15
|
* Add logging to main cache operationsJordan Cook2021-03-301-8/+23
|
* Update get_response + tests to check additional error typesJordan Cook2021-03-291-1/+1
|
* Remove some redundant module docstrings, and fix some ref linksJordan Cook2021-03-291-7/+0
|
* Handle AttributeErrors when a cached item can't be deserializedJordan Cook2021-03-291-1/+4
|
* Show warning when using pickle without itsdangerousJordan Cook2021-03-281-4/+11
|
* Pass along optional kwargs to all storage classes, and make default table ↵Jordan Cook2021-03-241-1/+1
| | | | names consistent across backends (`'http_cache'`)
* Enable DynamoDB integration test with GitHub Actions and local ↵Jordan Cook2021-03-241-1/+1
| | | | docker-compose; use in-memory database
* Combine storage classes from backends.storage.* with their respective ↵Jordan Cook2021-03-241-1/+1
| | | | backends in backends.*
* Add optional integration with intsdangerous for safer serializationJordan Cook2021-03-241-3/+46
|
* Rename BaseCache.keys_map property and its associated table to 'redirects'Jordan Cook2021-03-241-13/+11
|
* Add a 'urls' property on BaseCache to get all cached URLsJordan Cook2021-03-241-0/+8
| | | | Closes #155
* Consolidate expiration, pre-serializiation, and other response object logic ↵Jordan Cook2021-03-221-198/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | into CachedResponse class: * Replace `_RawStore` with `CachedHTTPResponse` class to wrap raw responses * Maintain support for streaming requests (#68) * Improve handling for generator usage * Add support for use with `pandas.read_csv()` and similar readers (#148) * Add support for use as a context manager (#148) * Add support for `decode_content` arg * Fix streaming requests when used with memory backend (#188) * Verified that `PreparedRequest.body` is always encoded in utf-8, so no need to detect encoding (Re: TODO note) * Response creation time and expiration time are stored as CachedResponse, so the `(response, timestamp)` tuple is no longer necessary * Rename `response.expire_after` and `response.cache_date` to `expires` and `created_at`, respectively, based on browser cache directives * Add optional `expire_after` param to `CachedSession.remove_old_responses()` * Make `CachedSession` members `allowable_codes, allowable_methods, filter_fn, old_data_on_error` public, since they can safely be modified after initialization * More type annotations and docstring updates * Move main cache documentation from `CacheMixin` to CachedSession`, since that's probably where a user would look first * Wrap temporary `_request_expire_after` in a contextmanager * Add intersphinx links for `urllib` classes & methods * Fix linting issues raised by flake8 * Start adding some unit tests using requests-mock tmp
* Some refactoring to reduce code complexity:Jordan Cook2021-03-181-7/+10
| | | | | | | | | * Pass per-request expiration in request params instead of setting as a temporary instance variable * Make use of dict ordering from python3.6+ in _normalize_parameters() * Add some more type annotations to `CachedSession` methods * Remove `expires_before` param from remove_old_entries, and always use the current time * Remove `relative_to` param from `CachedSession._determine_expiration_datetime` and use mock values in unit tests instead
* Add individual expire_after per request. (#177)Sebastian Höffner2021-03-051-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add individual expire_after per request. This commit adds a new feature to allow individual expire_after times per request. It involves using a custom CachedSession, PerRequestCachedSession, to be used as the session_factory. * Replace deprecated asserts in unit tests Additionally, some sockets are closed even on test failures. This removes some visual clutter when going through the results. * Update docs and README for per-request caching * Remove per_request and integrate behavior into CachedSession * Make test_return_old_data_on_error more reliable This is achieved by using a fixed date and mocking the backend calls to datetime as well. * Adjust per_request cache to new behavior Also adds HTTPBIN_URL environment variable as in test_cache * Add tests for the function determining the expiration datetime * Adjust backend to store expiration dates This also involves slightly different semantics for deletion, but the behavior stays the same. * Minor: black and isort * Update docs for request Add explanation for expire_after special cases, i.e. 'default' and 'cached' and how precedences are handled * Replace assert statements with methods * Remove invalid snippet from README * Remove invalid sentence from docs. * Make expires_before timezone-aware once And combine the checks for expiration * Simplify complexity by removing 'cached' keyword for expire_after
* Refactor CachedSession to be usable as a mixin classJordan Cook2021-03-041-2/+18
|
* Remove all python 2 compatibilityJordan Cook2021-02-261-7/+3
|
* Apply code formatting with black + isortJordan Cook2021-02-261-26/+36
|
* Removing extra check of whether key is in responses, unnecesasry after ↵Boris Danilovich2021-02-251-5/+1
| | | | copying the entire self.responses
* Making BaseCache use a copy of the dict when iterating over it, to avoid ↵Boris Danilovich2021-02-251-1/+1
| | | | iteration error in a multi-threaded environment
* Fix tests for new requests versionRoman Haritonov2016-08-181-1/+3
|
* Emulate raw stream is not consumed after content prefetch #68Roman Haritonov2016-07-301-1/+4
|
* #58 Ability to force removal of expired entriesRoman Haritonov2015-12-141-0/+15
|
* remove ignored parameters only from cachekeysYetAnotherNerd2015-09-241-3/+32
| | | | don't remove ignored parameters from the real request
* Fix requests 2.6.2 stream responses, fix mockingRoman Haritonov2015-04-291-0/+2
|
* #6 Add optional support for including headers to cache key in GET requestsRoman Haritonov2015-01-171-2/+11
|
* #33 Support for streaming requestsRoman Haritonov2014-12-121-1/+14
|
* Fix response history handling for requests 2.5.0Roman Haritonov2014-12-061-4/+18
|
* Add required _Store.release_conn() methodWillem de Groot2014-08-221-2/+3
|
* Make raw_response picklable by leaving only known picklable attributes (#13)Roman Haritonov2013-08-251-1/+7
|
* Forgive absent attributes (like 'raw') in old cache fileRoman Haritonov2013-08-191-1/+1
|
* Add raw attribute to pickled response for v1.2.3 compatibilityRoman Haritonov2013-08-191-1/+3
| | | | due to new way of handling cookies using response.raw._original_response.msg
* Fix issue with new hooks dispatchingRoman Haritonov2013-03-311-1/+9
|
* use UTC timeRoman Haritonov2013-02-021-1/+1
|
* cleanupRoman Haritonov2013-02-021-4/+2
|
* Fix create_key() for Py3Roman Haritonov2013-01-131-4/+17
|