summaryrefslogtreecommitdiff
path: root/requests_cache/backends
Commit message (Collapse)AuthorAgeFilesLines
* Add use_temp option to SQLite backendJordan Cook2021-04-222-8/+21
| | | | Closes #243
* Move storage class __str__ methods to base class, and just show keys instead ↵Jordan Cook2021-04-226-15/+3
| | | | of items
* Store responses for filesystem backend in a 'responses' subdirectory, to ↵Jordan Cook2021-04-221-5/+7
| | | | avoid deleting redirects.sqlite with clear()
* For SQLite and filesystem backends, resolve file paths in BaseStorage class ↵Jordan Cook2021-04-212-8/+6
| | | | rather than BaseCache class
* Add a filesystem backendJordan Cook2021-04-213-1/+93
|
* Use shared connection to create initial SQLite tableJordan Cook2021-04-211-1/+1
|
* Merge pull request #240 from jsemric/use-thread-local-connections-for-sqliteJordan Cook2021-04-211-41/+21
|\ | | | | Use thread local connections for sqlite
| * remove locking of sqlite connectionjsemric2021-04-211-18/+10
| |
| * do not lock connection on readjsemric2021-04-211-4/+10
| |
| * make bulk commit use thread-local connectionjsemric2021-04-211-26/+7
| |
| * use thread local sqlite connectionsjsemric2021-04-201-16/+17
| |
* | Fix DynamoDbDict.__iter__ to return keys instead of values; update tests to ↵Jordan Cook2021-04-201-1/+1
|/ | | | test for this
* Allow passing any valid backend connection kwargs via BaseCacheJordan Cook2021-04-197-100/+106
| | | | | | | | * 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
* Replace deprecated pymongo Collection.count() with estimated_document_count()v0.6.3Jordan Cook2021-04-192-2/+2
|
* 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`)
* Update GridFSPickleDict.__delitem__ to raise a KeyError for missing itemsJordan Cook2021-04-121-4/+8
|
* Add kwargs for AWS creds for DynamoDbDictJordan Cook2021-04-121-1/+11
|
* Update all backend-specific integration tests to fail quickly if not set up, ↵Jordan Cook2021-04-121-11/+11
| | | | rarther than silently ignoring or hanging
* Make parent dirs for new SQLite databasesJordan Cook2021-04-111-8/+18
|
* Demote most logging.info statements to debugJordan Cook2021-04-102-3/+3
|
* 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-033-26/+24
| | | | | | | | | | | | | | * 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
* Improve backend initialization:Jordan Cook2021-04-022-70/+79
| | | | | | | * Also allow passing a backend class (in addition to backend name and instance) * Detect duplicate params: Backends have different keyword args equivalent to the `cache_name` positional arg, for example `db_name`. If one of these is passed as a keyword arg, it results in a `TypeError` due to duplicate args (See #94). * For backends without dependencies installed, use a placeholder class to delay and re-raise the original `ImportError` * Add type annotations
* 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
|
* For SQLite backend, run VACUUM after remove_expired_responses()Jordan Cook2021-03-301-0/+10
|
* Move cache key utilities to a separate moduleJordan Cook2021-03-302-102/+12
|
* Add normalization for request jsonJordan Cook2021-03-302-5/+30
|
* 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-302-13/+16
|
* Add logging to main cache operationsJordan Cook2021-03-302-16/+33
|
* 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-292-13/+1
|
* Handle AttributeErrors when a cached item can't be deserializedJordan Cook2021-03-291-1/+4
|
* Show warning when using pickle without itsdangerousJordan Cook2021-03-282-4/+12
|
* Expose timeout parameter for SQLite backendJordan Cook2021-03-241-15/+15
|
* Pass along optional kwargs to all storage classes, and make default table ↵Jordan Cook2021-03-247-42/+41
| | | | 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-2412-537/+453
| | | | backends in backends.*
* Add optional integration with intsdangerous for safer serializationJordan Cook2021-03-246-45/+89
|
* Rename BaseCache.keys_map property and its associated table to 'redirects'Jordan Cook2021-03-246-18/+16
|
* 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-222-202/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add sanity checks to get_cache, clear, and remove_expired_responses to make ↵Jordan Cook2021-03-042-4/+4
| | | | sure CachedSession is installed
* Refactor CachedSession to be usable as a mixin classJordan Cook2021-03-049-12/+28
|