requests-cache 1.2.0__tar.gz → 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- requests_cache-1.3.0/.gitignore +42 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/PKG-INFO +34 -43
- {requests_cache-1.2.0 → requests_cache-1.3.0}/README.md +2 -2
- requests_cache-1.3.0/pyproject.toml +187 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/__init__.py +0 -4
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/_utils.py +4 -1
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/backends/__init__.py +15 -3
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/backends/base.py +9 -11
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/backends/dynamodb.py +8 -1
- requests_cache-1.3.0/requests_cache/backends/filesystem.py +509 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/backends/gridfs.py +9 -5
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/backends/mongodb.py +6 -5
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/backends/redis.py +15 -17
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/backends/sqlite.py +39 -39
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/cache_keys.py +43 -12
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/models/__init__.py +1 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/models/raw_response.py +7 -3
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/models/response.py +9 -5
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/patcher.py +12 -6
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/policy/__init__.py +1 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/policy/actions.py +50 -16
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/policy/directives.py +11 -4
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/policy/expiration.py +10 -3
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/policy/settings.py +4 -1
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/serializers/__init__.py +14 -3
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/serializers/cattrs.py +16 -6
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/serializers/pipeline.py +12 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/serializers/preconf.py +61 -35
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/session.py +11 -1
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/benchmark_serializers.py +1 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/compat/httpbin_sample.test-db +0 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/compat/test_requests_mock_combine_cache.py +1 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/compat/test_requests_mock_disable_cache.py +1 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/compat/test_requests_mock_load_cache.py +1 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/compat/test_responses_load_cache.py +4 -1
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/conftest.py +46 -9
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/generate_test_db.py +4 -2
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/integration/base_cache_test.py +14 -10
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/integration/base_storage_test.py +56 -3
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/integration/test_dynamodb.py +7 -2
- requests_cache-1.3.0/tests/integration/test_filesystem.py +562 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/integration/test_mongodb.py +32 -14
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/integration/test_redis.py +5 -1
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/integration/test_sqlite.py +24 -58
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/unit/models/test_response.py +9 -5
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/unit/policy/test_actions.py +96 -5
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/unit/policy/test_expiration.py +30 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/unit/test_base_cache.py +11 -7
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/unit/test_cache_keys.py +76 -4
- requests_cache-1.3.0/tests/unit/test_normalize.py +26 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/unit/test_patcher.py +1 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/unit/test_serializers.py +43 -35
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/unit/test_session.py +83 -23
- requests_cache-1.2.0/.readthedocs.yml +0 -19
- requests_cache-1.2.0/CONTRIBUTING.md +0 -204
- requests_cache-1.2.0/CONTRIBUTORS.md +0 -155
- requests_cache-1.2.0/HISTORY.md +0 -670
- requests_cache-1.2.0/docker-compose.yml +0 -46
- requests_cache-1.2.0/docs/404.rst +0 -6
- requests_cache-1.2.0/docs/Dockerfile +0 -5
- requests_cache-1.2.0/docs/_static/dynamodb.png +0 -0
- requests_cache-1.2.0/docs/_static/dynamodb_32px.png +0 -0
- requests_cache-1.2.0/docs/_static/dynamodb_create_table.png +0 -0
- requests_cache-1.2.0/docs/_static/dynamodb_items.png +0 -0
- requests_cache-1.2.0/docs/_static/dynamodb_response.png +0 -0
- requests_cache-1.2.0/docs/_static/favicon.ico +0 -0
- requests_cache-1.2.0/docs/_static/file-json.png +0 -0
- requests_cache-1.2.0/docs/_static/file-json_32px.png +0 -0
- requests_cache-1.2.0/docs/_static/file-pickle.png +0 -0
- requests_cache-1.2.0/docs/_static/file-pickle_32px.png +0 -0
- requests_cache-1.2.0/docs/_static/file-toml.png +0 -0
- requests_cache-1.2.0/docs/_static/file-toml_32px.png +0 -0
- requests_cache-1.2.0/docs/_static/file-yaml.png +0 -0
- requests_cache-1.2.0/docs/_static/file-yaml_32px.png +0 -0
- requests_cache-1.2.0/docs/_static/file-yaml_32px.png.png +0 -0
- requests_cache-1.2.0/docs/_static/files-generic.png +0 -0
- requests_cache-1.2.0/docs/_static/files-generic_32px.png +0 -0
- requests_cache-1.2.0/docs/_static/files-json.png +0 -0
- requests_cache-1.2.0/docs/_static/files-json_32px.png +0 -0
- requests_cache-1.2.0/docs/_static/memcached.png +0 -0
- requests_cache-1.2.0/docs/_static/memcached_32px.png +0 -0
- requests_cache-1.2.0/docs/_static/memory_32px.png +0 -0
- requests_cache-1.2.0/docs/_static/mongodb.png +0 -0
- requests_cache-1.2.0/docs/_static/mongodb_32px.png +0 -0
- requests_cache-1.2.0/docs/_static/mongodb_vscode.png +0 -0
- requests_cache-1.2.0/docs/_static/redis.png +0 -0
- requests_cache-1.2.0/docs/_static/redis_32px.png +0 -0
- requests_cache-1.2.0/docs/_static/requests-cache-gh-preview.png +0 -0
- requests_cache-1.2.0/docs/_static/requests-cache-icon.png +0 -0
- requests_cache-1.2.0/docs/_static/requests-cache-logo-dark.webp +0 -0
- requests_cache-1.2.0/docs/_static/requests-cache-logo-header.png +0 -0
- requests_cache-1.2.0/docs/_static/requests-cache-logo-light.webp +0 -0
- requests_cache-1.2.0/docs/_static/sqlite.png +0 -0
- requests_cache-1.2.0/docs/_static/sqlite_32px.png +0 -0
- requests_cache-1.2.0/docs/_static/table.css +0 -23
- requests_cache-1.2.0/docs/_static/toml.png +0 -0
- requests_cache-1.2.0/docs/_templates/module.rst_t +0 -15
- requests_cache-1.2.0/docs/_templates/package.rst_t +0 -10
- requests_cache-1.2.0/docs/api/requests_cache.session.md +0 -17
- requests_cache-1.2.0/docs/conf.py +0 -168
- requests_cache-1.2.0/docs/docker-compose.yml +0 -14
- requests_cache-1.2.0/docs/examples.md +0 -293
- requests_cache-1.2.0/docs/index.md +0 -38
- requests_cache-1.2.0/docs/project_info/code_of_conduct.md +0 -66
- requests_cache-1.2.0/docs/project_info/codeshelter.md +0 -19
- requests_cache-1.2.0/docs/project_info/contributing.md +0 -11
- requests_cache-1.2.0/docs/project_info/contributors.md +0 -4
- requests_cache-1.2.0/docs/project_info/history.md +0 -5
- requests_cache-1.2.0/docs/project_info/related_projects.md +0 -30
- requests_cache-1.2.0/docs/project_info.md +0 -11
- requests_cache-1.2.0/docs/reference.md +0 -37
- requests_cache-1.2.0/docs/sample_data/sample_response_binary.json +0 -36
- requests_cache-1.2.0/docs/sample_data/sample_response_binary.yaml +0 -37
- requests_cache-1.2.0/docs/sample_data/sample_response_json.json +0 -56
- requests_cache-1.2.0/docs/sample_data/sample_response_json.yaml +0 -42
- requests_cache-1.2.0/docs/user_guide/advanced_requests.md +0 -58
- requests_cache-1.2.0/docs/user_guide/backends/dynamodb.md +0 -134
- requests_cache-1.2.0/docs/user_guide/backends/filesystem.md +0 -50
- requests_cache-1.2.0/docs/user_guide/backends/gridfs.md +0 -23
- requests_cache-1.2.0/docs/user_guide/backends/mongodb.md +0 -103
- requests_cache-1.2.0/docs/user_guide/backends/redis.md +0 -73
- requests_cache-1.2.0/docs/user_guide/backends/sqlite.md +0 -107
- requests_cache-1.2.0/docs/user_guide/backends.md +0 -170
- requests_cache-1.2.0/docs/user_guide/compatibility.md +0 -212
- requests_cache-1.2.0/docs/user_guide/expiration.md +0 -294
- requests_cache-1.2.0/docs/user_guide/files.md +0 -104
- requests_cache-1.2.0/docs/user_guide/filtering.md +0 -82
- requests_cache-1.2.0/docs/user_guide/general.md +0 -112
- requests_cache-1.2.0/docs/user_guide/headers.md +0 -80
- requests_cache-1.2.0/docs/user_guide/inspection.md +0 -109
- requests_cache-1.2.0/docs/user_guide/installation.md +0 -44
- requests_cache-1.2.0/docs/user_guide/matching.md +0 -180
- requests_cache-1.2.0/docs/user_guide/security.md +0 -79
- requests_cache-1.2.0/docs/user_guide/serializers.md +0 -202
- requests_cache-1.2.0/docs/user_guide/troubleshooting.md +0 -112
- requests_cache-1.2.0/docs/user_guide.md +0 -29
- requests_cache-1.2.0/docs/vector/requests-cache-logo-header.svg +0 -126
- requests_cache-1.2.0/docs/vector/requests-cache-logo.svg +0 -127
- requests_cache-1.2.0/docs/vector/requests_cache_icon.svg +0 -111
- requests_cache-1.2.0/examples/README.md +0 -4
- requests_cache-1.2.0/examples/basic_patching.py +0 -41
- requests_cache-1.2.0/examples/basic_sessions.py +0 -35
- requests_cache-1.2.0/examples/benchmark.py +0 -106
- requests_cache-1.2.0/examples/cloudformation.yml +0 -34
- requests_cache-1.2.0/examples/convert_cache.py +0 -46
- requests_cache-1.2.0/examples/custom_request_matcher.py +0 -64
- requests_cache-1.2.0/examples/expiration.py +0 -50
- requests_cache-1.2.0/examples/external_config.py +0 -29
- requests_cache-1.2.0/examples/external_config.yml +0 -16
- requests_cache-1.2.0/examples/generate_test_db.py +0 -123
- requests_cache-1.2.0/examples/github_actions.yml +0 -27
- requests_cache-1.2.0/examples/log_requests.py +0 -46
- requests_cache-1.2.0/examples/pygithub.py +0 -118
- requests_cache-1.2.0/examples/rps_graph.png +0 -0
- requests_cache-1.2.0/examples/rps_graph.py +0 -123
- requests_cache-1.2.0/examples/threads.py +0 -39
- requests_cache-1.2.0/examples/time_machine_backtesting.py +0 -39
- requests_cache-1.2.0/examples/url_patterns.py +0 -53
- requests_cache-1.2.0/examples/vcr.py +0 -99
- requests_cache-1.2.0/pyproject.toml +0 -202
- requests_cache-1.2.0/requests_cache/backends/filesystem.py +0 -144
- requests_cache-1.2.0/tests/integration/test_filesystem.py +0 -123
- requests_cache-1.2.0/tests/integration/test_upgrade.py +0 -23
- requests_cache-1.2.0/tests/sample_data/sample.db.0.3.0 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.4.0 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.4.13 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.5.0 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.5.1 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.5.2 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.6.0 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.6.1 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.6.2 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.6.3 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.6.4 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.7.0 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.7.1 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.7.2 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.7.3 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.7.4 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.7.5 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.8.0 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.8.1 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.9.0 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.9.1 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.9.2 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.9.3 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.9.4 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.9.5 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.9.6 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.9.7 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.0.9.8 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.1.0.0 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.1.1.0 +0 -0
- requests_cache-1.2.0/tests/sample_data/sample.db.1.2.0 +0 -0
- requests_cache-1.2.0/tests/sample_data/vcr_requests_cache.yaml +0 -46
- requests_cache-1.2.0/tests/sample_data/vcr_vcrpy.yaml +0 -77
- {requests_cache-1.2.0 → requests_cache-1.3.0}/LICENSE +0 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/models/base.py +0 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/models/request.py +0 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/requests_cache/py.typed +0 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/README.md +0 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/__init__.py +0 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/compat/README.md +0 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/integration/__init__.py +0 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/integration/test_memory.py +0 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/unit/models/test_base.py +0 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/unit/models/test_raw_response.py +0 -0
- {requests_cache-1.2.0 → requests_cache-1.3.0}/tests/unit/models/test_request.py +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
build/
|
|
2
|
+
dist/
|
|
3
|
+
downloads/
|
|
4
|
+
example_cache/
|
|
5
|
+
http_cache/
|
|
6
|
+
benchmark_cache/
|
|
7
|
+
scratch
|
|
8
|
+
venv/
|
|
9
|
+
|
|
10
|
+
*.db
|
|
11
|
+
*.egg
|
|
12
|
+
*.egg-info
|
|
13
|
+
*.py[cod]
|
|
14
|
+
*.sqlite
|
|
15
|
+
*.sqlite-journal
|
|
16
|
+
.venv
|
|
17
|
+
Pipfile
|
|
18
|
+
profile.json
|
|
19
|
+
|
|
20
|
+
# JS
|
|
21
|
+
node_modules/
|
|
22
|
+
package-lock.json
|
|
23
|
+
package.json
|
|
24
|
+
|
|
25
|
+
# Editors
|
|
26
|
+
.~*
|
|
27
|
+
.idea/
|
|
28
|
+
.vim/
|
|
29
|
+
.vscode/
|
|
30
|
+
|
|
31
|
+
# Test / coverage reports
|
|
32
|
+
.coverage
|
|
33
|
+
.coverage.*
|
|
34
|
+
.COVERAGE.*
|
|
35
|
+
.mypy_cache/
|
|
36
|
+
.nox/
|
|
37
|
+
test-reports/
|
|
38
|
+
|
|
39
|
+
# Sphinx / Readthedocs
|
|
40
|
+
docs/_build/
|
|
41
|
+
docs/modules/
|
|
42
|
+
docs/requirements.txt
|
|
@@ -1,66 +1,58 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: requests-cache
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: A persistent cache for python requests
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Author: Roman Haritonov
|
|
9
|
-
|
|
5
|
+
Project-URL: homepage, https://github.com/requests-cache/requests-cache
|
|
6
|
+
Project-URL: repository, https://github.com/requests-cache/requests-cache
|
|
7
|
+
Project-URL: documentation, https://requests-cache.readthedocs.io
|
|
8
|
+
Author: Jordan Cook, Roman Haritonov
|
|
9
|
+
License-Expression: BSD-2-Clause
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: cache,dynamodb,http,http-client,mongodb,performance,python-requests,redis,requests,sqlite,web,webscraping
|
|
10
12
|
Classifier: Development Status :: 5 - Production/Stable
|
|
11
13
|
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: License :: OSI Approved :: BSD License
|
|
13
14
|
Classifier: Programming Language :: Python :: 3
|
|
14
15
|
Classifier: Programming Language :: Python :: 3.8
|
|
15
16
|
Classifier: Programming Language :: Python :: 3.9
|
|
16
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
17
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
22
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
23
|
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.8
|
|
25
|
+
Requires-Dist: attrs>=21.2
|
|
26
|
+
Requires-Dist: cattrs>=22.2
|
|
27
|
+
Requires-Dist: platformdirs>=2.5
|
|
28
|
+
Requires-Dist: requests>=2.22
|
|
29
|
+
Requires-Dist: url-normalize>=2.0
|
|
30
|
+
Requires-Dist: urllib3>=1.25.5
|
|
21
31
|
Provides-Extra: all
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
Requires-Dist: boto3>=1.15; extra == 'all'
|
|
33
|
+
Requires-Dist: botocore>=1.18; extra == 'all'
|
|
34
|
+
Requires-Dist: itsdangerous>=2.0; extra == 'all'
|
|
35
|
+
Requires-Dist: orjson>=3.0; extra == 'all'
|
|
36
|
+
Requires-Dist: pymongo>=3; extra == 'all'
|
|
37
|
+
Requires-Dist: pyyaml>=6.0.1; extra == 'all'
|
|
38
|
+
Requires-Dist: redis>=3; extra == 'all'
|
|
39
|
+
Requires-Dist: ujson>=5.4; extra == 'all'
|
|
24
40
|
Provides-Extra: dynamodb
|
|
25
|
-
|
|
41
|
+
Requires-Dist: boto3>=1.15; extra == 'dynamodb'
|
|
42
|
+
Requires-Dist: botocore>=1.18; extra == 'dynamodb'
|
|
26
43
|
Provides-Extra: mongodb
|
|
44
|
+
Requires-Dist: pymongo>=3; extra == 'mongodb'
|
|
27
45
|
Provides-Extra: redis
|
|
46
|
+
Requires-Dist: redis>=3; extra == 'redis'
|
|
28
47
|
Provides-Extra: security
|
|
48
|
+
Requires-Dist: itsdangerous>=2.0; extra == 'security'
|
|
29
49
|
Provides-Extra: yaml
|
|
30
|
-
Requires-Dist:
|
|
31
|
-
Requires-Dist: boto3 (>=1.15) ; extra == "dynamodb" or extra == "all"
|
|
32
|
-
Requires-Dist: botocore (>=1.18) ; extra == "dynamodb" or extra == "all"
|
|
33
|
-
Requires-Dist: bson (>=0.5) ; extra == "bson"
|
|
34
|
-
Requires-Dist: cattrs (>=22.2)
|
|
35
|
-
Requires-Dist: furo (>=2023.3,<2024.0) ; extra == "docs"
|
|
36
|
-
Requires-Dist: itsdangerous (>=2.0) ; extra == "security" or extra == "all"
|
|
37
|
-
Requires-Dist: linkify-it-py (>=2.0,<3.0) ; extra == "docs"
|
|
38
|
-
Requires-Dist: myst-parser (>=1.0,<2.0) ; extra == "docs"
|
|
39
|
-
Requires-Dist: platformdirs (>=2.5)
|
|
40
|
-
Requires-Dist: pymongo (>=3) ; extra == "mongodb" or extra == "all"
|
|
41
|
-
Requires-Dist: pyyaml (>=6.0.1) ; extra == "yaml" or extra == "all"
|
|
42
|
-
Requires-Dist: redis (>=3) ; extra == "redis" or extra == "all"
|
|
43
|
-
Requires-Dist: requests (>=2.22)
|
|
44
|
-
Requires-Dist: sphinx (>=5.0.2,<6.0.0) ; extra == "docs"
|
|
45
|
-
Requires-Dist: sphinx-autodoc-typehints (>=1.19) ; extra == "docs"
|
|
46
|
-
Requires-Dist: sphinx-automodapi (>=0.14) ; extra == "docs"
|
|
47
|
-
Requires-Dist: sphinx-copybutton (>=0.5) ; extra == "docs"
|
|
48
|
-
Requires-Dist: sphinx-design (>=0.2) ; extra == "docs"
|
|
49
|
-
Requires-Dist: sphinx-notfound-page (>=0.8) ; extra == "docs"
|
|
50
|
-
Requires-Dist: sphinxcontrib-apidoc (>=0.3) ; extra == "docs"
|
|
51
|
-
Requires-Dist: sphinxext-opengraph (>=0.9) ; extra == "docs"
|
|
52
|
-
Requires-Dist: ujson (>=5.4) ; extra == "json" or extra == "all"
|
|
53
|
-
Requires-Dist: url-normalize (>=1.4)
|
|
54
|
-
Requires-Dist: urllib3 (>=1.25.5)
|
|
55
|
-
Project-URL: Changelog, https://requests-cache.readthedocs.io/en/stable/project_info/history.html
|
|
56
|
-
Project-URL: Documentation, https://requests-cache.readthedocs.io
|
|
57
|
-
Project-URL: Issues, https://github.com/requests-cache/requests-cache/issues
|
|
58
|
-
Project-URL: Repository, https://github.com/requests-cache/requests-cache
|
|
50
|
+
Requires-Dist: pyyaml>=6.0.1; extra == 'yaml'
|
|
59
51
|
Description-Content-Type: text/markdown
|
|
60
52
|
|
|
61
53
|
[](https://requests-cache.readthedocs.io)
|
|
62
54
|
|
|
63
|
-
[](https://github.com/requests-cache/requests-cache/actions)
|
|
64
56
|
[](https://codecov.io/gh/requests-cache/requests-cache)
|
|
65
57
|
[](https://requests-cache.readthedocs.io/en/stable/)
|
|
66
58
|
[](https://www.codeshelter.co/)
|
|
@@ -194,7 +186,7 @@ session = CachedSession(
|
|
|
194
186
|
expire_after=timedelta(days=1), # Otherwise expire responses after one day
|
|
195
187
|
allowable_codes=[200, 400], # Cache 400 responses as a solemn reminder of your failures
|
|
196
188
|
allowable_methods=['GET', 'POST'], # Cache whatever HTTP methods you want
|
|
197
|
-
ignored_parameters=['api_key'], # Don't match this request param, and redact
|
|
189
|
+
ignored_parameters=['api_key'], # Don't match this request param, and redact it from the cache
|
|
198
190
|
match_headers=['Accept-Language'], # Cache a different response per language
|
|
199
191
|
stale_if_error=True, # In case of request errors, use stale cache data if possible
|
|
200
192
|
)
|
|
@@ -209,4 +201,3 @@ To find out more about what you can do with requests-cache, see:
|
|
|
209
201
|
* [API Reference](https://requests-cache.readthedocs.io/en/stable/reference.html)
|
|
210
202
|
* [Project Info](https://requests-cache.readthedocs.io/en/stable/project_info.html)
|
|
211
203
|
<!-- END-RTD-IGNORE -->
|
|
212
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[](https://requests-cache.readthedocs.io)
|
|
2
2
|
|
|
3
|
-
[](https://github.com/requests-cache/requests-cache/actions)
|
|
4
4
|
[](https://codecov.io/gh/requests-cache/requests-cache)
|
|
5
5
|
[](https://requests-cache.readthedocs.io/en/stable/)
|
|
6
6
|
[](https://www.codeshelter.co/)
|
|
@@ -134,7 +134,7 @@ session = CachedSession(
|
|
|
134
134
|
expire_after=timedelta(days=1), # Otherwise expire responses after one day
|
|
135
135
|
allowable_codes=[200, 400], # Cache 400 responses as a solemn reminder of your failures
|
|
136
136
|
allowable_methods=['GET', 'POST'], # Cache whatever HTTP methods you want
|
|
137
|
-
ignored_parameters=['api_key'], # Don't match this request param, and redact
|
|
137
|
+
ignored_parameters=['api_key'], # Don't match this request param, and redact it from the cache
|
|
138
138
|
match_headers=['Accept-Language'], # Cache a different response per language
|
|
139
139
|
stale_if_error=True, # In case of request errors, use stale cache data if possible
|
|
140
140
|
)
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = 'requests-cache'
|
|
3
|
+
version = '1.3.0'
|
|
4
|
+
description = 'A persistent cache for python requests'
|
|
5
|
+
authors = [{name='Jordan Cook'}, {name='Roman Haritonov'}]
|
|
6
|
+
license = 'BSD-2-Clause'
|
|
7
|
+
readme = 'README.md'
|
|
8
|
+
keywords = [
|
|
9
|
+
'requests',
|
|
10
|
+
'python-requests',
|
|
11
|
+
'cache',
|
|
12
|
+
'http',
|
|
13
|
+
'http-client',
|
|
14
|
+
'web',
|
|
15
|
+
'webscraping',
|
|
16
|
+
'performance',
|
|
17
|
+
'sqlite',
|
|
18
|
+
'redis',
|
|
19
|
+
'mongodb',
|
|
20
|
+
'dynamodb',
|
|
21
|
+
]
|
|
22
|
+
classifiers = [
|
|
23
|
+
'Development Status :: 5 - Production/Stable',
|
|
24
|
+
'Intended Audience :: Developers',
|
|
25
|
+
'Programming Language :: Python :: 3',
|
|
26
|
+
'Programming Language :: Python :: 3.8',
|
|
27
|
+
'Programming Language :: Python :: 3.9',
|
|
28
|
+
'Programming Language :: Python :: 3.10',
|
|
29
|
+
'Programming Language :: Python :: 3.11',
|
|
30
|
+
'Programming Language :: Python :: 3.12',
|
|
31
|
+
'Programming Language :: Python :: 3.13',
|
|
32
|
+
'Programming Language :: Python :: 3.14',
|
|
33
|
+
'Topic :: Software Development :: Libraries :: Python Modules',
|
|
34
|
+
'Typing :: Typed',
|
|
35
|
+
]
|
|
36
|
+
requires-python = '>=3.8'
|
|
37
|
+
|
|
38
|
+
# Required dependencies
|
|
39
|
+
dependencies = [
|
|
40
|
+
'requests >=2.22', # Needs no introduction
|
|
41
|
+
'urllib3 >=1.25.5', # Use a slightly newer version than required by requests (for bugfixes)
|
|
42
|
+
'attrs >=21.2', # For response data models
|
|
43
|
+
'cattrs >=22.2', # For response serialization
|
|
44
|
+
'platformdirs >=2.5', # For features that use platform-specific system directories
|
|
45
|
+
'url-normalize >=2.0', # For more accurate request matching
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[project.urls]
|
|
49
|
+
homepage = 'https://github.com/requests-cache/requests-cache'
|
|
50
|
+
repository = 'https://github.com/requests-cache/requests-cache'
|
|
51
|
+
documentation = 'https://requests-cache.readthedocs.io'
|
|
52
|
+
|
|
53
|
+
[project.optional-dependencies]
|
|
54
|
+
# Optional backend and serialization dependencies
|
|
55
|
+
dynamodb = ['boto3>=1.15', 'botocore>=1.18']
|
|
56
|
+
mongodb = ['pymongo>=3']
|
|
57
|
+
redis = ['redis>=3']
|
|
58
|
+
security = ['itsdangerous>=2.0']
|
|
59
|
+
yaml = ['pyyaml>=6.0.1']
|
|
60
|
+
all = [
|
|
61
|
+
'boto3 >=1.15',
|
|
62
|
+
'botocore >=1.18',
|
|
63
|
+
'itsdangerous >=2.0',
|
|
64
|
+
'orjson >=3.0',
|
|
65
|
+
'pymongo >=3',
|
|
66
|
+
'pyyaml >=6.0.1',
|
|
67
|
+
'redis >=3',
|
|
68
|
+
'ujson >=5.4',
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
[dependency-groups]
|
|
72
|
+
# Test dependencies and local development tools
|
|
73
|
+
dev = [
|
|
74
|
+
'coverage >=7.2',
|
|
75
|
+
'psutil >=5.0',
|
|
76
|
+
'pytest >=8.2',
|
|
77
|
+
'pytest-clarity >=1.0.1',
|
|
78
|
+
'pytest-cov >=3.0',
|
|
79
|
+
'pytest-pretty >=1.2',
|
|
80
|
+
'pytest-rerunfailures >=10.1',
|
|
81
|
+
'pytest-xdist >=2.2',
|
|
82
|
+
'requests-mock ~=1.12',
|
|
83
|
+
'responses >=0.19',
|
|
84
|
+
'tenacity ~=8.0',
|
|
85
|
+
'time-machine ~=2.9; implementation_name != "pypy"',
|
|
86
|
+
'nox >=2024.4',
|
|
87
|
+
'prek >=0.2',
|
|
88
|
+
'rich >=10.0',
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
# Documentation dependencies
|
|
92
|
+
docs = [
|
|
93
|
+
'furo ~=2025.7 ; python_version>="3.11"',
|
|
94
|
+
'linkify-it-py >=2.0 ; python_version>="3.11"',
|
|
95
|
+
'myst-parser >=3.0 ; python_version>="3.11"',
|
|
96
|
+
'sphinx ~=8.2.3 ; python_version>="3.11"',
|
|
97
|
+
'sphinx-autobuild ~=2024.10 ; python_version>="3.11"',
|
|
98
|
+
'sphinx-autodoc-typehints ~=3.2 ; python_version>="3.11"',
|
|
99
|
+
'sphinx-automodapi ~=0.20 ; python_version>="3.11"',
|
|
100
|
+
'sphinx-copybutton >=0.5 ; python_version>="3.11"',
|
|
101
|
+
'sphinx-design >=0.6 ; python_version>="3.11"',
|
|
102
|
+
'sphinx-notfound-page >=1.0 ; python_version>="3.11"',
|
|
103
|
+
'sphinx-llms-txt >=0.5 ; python_version>="3.11"',
|
|
104
|
+
'sphinx-sitemap >=2.8 ; python_version>="3.11"',
|
|
105
|
+
'sphinxcontrib-apidoc >=0.3 ; python_version>="3.11"',
|
|
106
|
+
'sphinxext-opengraph >=0.9 ; python_version>="3.11"',
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
[build-system]
|
|
110
|
+
requires = ['hatchling>=1.0.0']
|
|
111
|
+
build-backend = 'hatchling.build'
|
|
112
|
+
|
|
113
|
+
[tool.hatch.build]
|
|
114
|
+
only-include = ['requests_cache']
|
|
115
|
+
force-include = {'README.md' = 'requests_cache/README.md'}
|
|
116
|
+
|
|
117
|
+
# Include tests in sdist, except for sample data, which is too large to package
|
|
118
|
+
[tool.hatch.build.targets.sdist]
|
|
119
|
+
only-include = ['requests_cache', 'tests']
|
|
120
|
+
exclude = [
|
|
121
|
+
"tests/sample_data",
|
|
122
|
+
"tests/integration/test_upgrade.py",
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
[tool.coverage.html]
|
|
126
|
+
directory = 'test-reports'
|
|
127
|
+
|
|
128
|
+
[tool.coverage.xml]
|
|
129
|
+
output = 'test-reports/coverage.xml'
|
|
130
|
+
|
|
131
|
+
[tool.coverage.run]
|
|
132
|
+
branch = true
|
|
133
|
+
source = ['requests_cache']
|
|
134
|
+
omit = [
|
|
135
|
+
'requests_cache/__init__.py',
|
|
136
|
+
'requests_cache/backends/__init__.py',
|
|
137
|
+
'requests_cache/models/__init__.py',
|
|
138
|
+
'requests_cache/serializers/__init__.py',
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
[tool.coverage.report]
|
|
142
|
+
exclude_lines = [
|
|
143
|
+
'pragma: no cover',
|
|
144
|
+
'if TYPE_CHECKING:',
|
|
145
|
+
'if logger.level',
|
|
146
|
+
'except ImportError:',
|
|
147
|
+
]
|
|
148
|
+
|
|
149
|
+
[tool.mypy]
|
|
150
|
+
python_version = 3.8
|
|
151
|
+
ignore_missing_imports = true
|
|
152
|
+
warn_redundant_casts = true
|
|
153
|
+
warn_unused_ignores = true
|
|
154
|
+
warn_unreachable = true
|
|
155
|
+
show_error_codes = true
|
|
156
|
+
show_column_numbers = true
|
|
157
|
+
pretty = true
|
|
158
|
+
|
|
159
|
+
[tool.ruff]
|
|
160
|
+
fix = true
|
|
161
|
+
unsafe-fixes = true
|
|
162
|
+
line-length = 100
|
|
163
|
+
output-format = 'grouped'
|
|
164
|
+
target-version = 'py38'
|
|
165
|
+
exclude = ['examples/']
|
|
166
|
+
|
|
167
|
+
[tool.ruff.format]
|
|
168
|
+
quote-style = 'single'
|
|
169
|
+
|
|
170
|
+
[tool.ruff.lint]
|
|
171
|
+
select = ['B', 'C4', 'C90', 'E', 'F']
|
|
172
|
+
ignore = ['B023']
|
|
173
|
+
|
|
174
|
+
[tool.ruff.lint.isort]
|
|
175
|
+
known-first-party = ['tests']
|
|
176
|
+
|
|
177
|
+
# Wrap lines to 100 chars, but don't error on unwrappable lines until 120 chars
|
|
178
|
+
[tool.ruff.lint.pycodestyle]
|
|
179
|
+
max-line-length = 120
|
|
180
|
+
|
|
181
|
+
[tool.typos]
|
|
182
|
+
files.extend-exclude = [
|
|
183
|
+
'.all-contributorsrc',
|
|
184
|
+
'CONTRIBUTORS.md',
|
|
185
|
+
'docs/sample_data',
|
|
186
|
+
'tests/sample_data',
|
|
187
|
+
]
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Minor internal utility functions that don't really belong anywhere else"""
|
|
2
|
+
|
|
2
3
|
from contextlib import contextmanager
|
|
3
4
|
from inspect import signature
|
|
4
5
|
from logging import getLogger
|
|
@@ -6,7 +7,7 @@ from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Tupl
|
|
|
6
7
|
|
|
7
8
|
from urllib3 import filepost
|
|
8
9
|
|
|
9
|
-
FORM_BOUNDARY = '
|
|
10
|
+
FORM_BOUNDARY = '--requests-cache-form-boundary--'
|
|
10
11
|
|
|
11
12
|
KwargDict = Dict[str, Any]
|
|
12
13
|
logger = getLogger('requests_cache')
|
|
@@ -51,6 +52,8 @@ def get_placeholder_class(original_exception: Optional[Exception] = None):
|
|
|
51
52
|
raise original_exception or ImportError(msg)
|
|
52
53
|
|
|
53
54
|
class Placeholder:
|
|
55
|
+
name = 'placeholder'
|
|
56
|
+
|
|
54
57
|
def __init__(self, *args, **kwargs):
|
|
55
58
|
_log_error()
|
|
56
59
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"""Classes and functions for cache persistence. See :ref:`backends` for general usage info."""
|
|
2
|
+
|
|
2
3
|
# ruff: noqa: F401
|
|
3
4
|
from logging import getLogger
|
|
4
5
|
from pathlib import Path
|
|
5
6
|
from typing import Callable, Dict, Iterable, Optional, Type, Union
|
|
7
|
+
from warnings import warn
|
|
6
8
|
|
|
7
9
|
from .._utils import get_placeholder_class, get_valid_kwargs
|
|
8
10
|
from .base import BaseCache, BaseStorage, DictStorage
|
|
@@ -42,9 +44,9 @@ except ImportError as e:
|
|
|
42
44
|
SQLiteCache = SQLiteDict = get_placeholder_class(e) # type: ignore
|
|
43
45
|
|
|
44
46
|
try:
|
|
45
|
-
from .filesystem import FileCache, FileDict
|
|
47
|
+
from .filesystem import FileCache, FileDict, LRUFileDict
|
|
46
48
|
except ImportError as e:
|
|
47
|
-
FileCache = FileDict = get_placeholder_class(e) # type: ignore
|
|
49
|
+
FileCache = FileDict = LRUFileDict = get_placeholder_class(e) # type: ignore
|
|
48
50
|
|
|
49
51
|
|
|
50
52
|
BACKEND_CLASSES = {
|
|
@@ -73,8 +75,18 @@ def init_backend(
|
|
|
73
75
|
|
|
74
76
|
# Already a backend instance
|
|
75
77
|
if isinstance(backend, BaseCache):
|
|
76
|
-
|
|
78
|
+
# Database names, file paths, etc. cannot be reliably updated after initialization, so
|
|
79
|
+
# warn if the user passes both `cache_name` and a backend instance
|
|
80
|
+
from ..policy import DEFAULT_CACHE_NAME
|
|
81
|
+
|
|
82
|
+
if cache_name and cache_name != DEFAULT_CACHE_NAME:
|
|
77
83
|
backend.cache_name = str(cache_name)
|
|
84
|
+
warn(
|
|
85
|
+
'`cache_name` cannot be set after backend initialization; '
|
|
86
|
+
'please pass it to the backend class instead',
|
|
87
|
+
DeprecationWarning,
|
|
88
|
+
stacklevel=3,
|
|
89
|
+
)
|
|
78
90
|
return backend
|
|
79
91
|
# If no backend is specified, use SQLite as default, unless the environment doesn't support it
|
|
80
92
|
elif not backend:
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
:classes-only:
|
|
5
5
|
:nosignatures:
|
|
6
6
|
"""
|
|
7
|
+
|
|
7
8
|
from __future__ import annotations
|
|
8
9
|
|
|
9
10
|
from abc import ABC
|
|
@@ -11,15 +12,7 @@ from collections import UserDict
|
|
|
11
12
|
from datetime import datetime
|
|
12
13
|
from logging import getLogger
|
|
13
14
|
from pickle import PickleError
|
|
14
|
-
from typing import
|
|
15
|
-
TYPE_CHECKING,
|
|
16
|
-
Iterable,
|
|
17
|
-
Iterator,
|
|
18
|
-
List,
|
|
19
|
-
MutableMapping,
|
|
20
|
-
Optional,
|
|
21
|
-
TypeVar,
|
|
22
|
-
)
|
|
15
|
+
from typing import TYPE_CHECKING, Iterable, Iterator, List, MutableMapping, Optional, TypeVar
|
|
23
16
|
from warnings import warn
|
|
24
17
|
|
|
25
18
|
from requests import Request, Response
|
|
@@ -126,6 +119,7 @@ class BaseCache:
|
|
|
126
119
|
return key_fn(
|
|
127
120
|
request=request,
|
|
128
121
|
ignored_parameters=self._settings.ignored_parameters,
|
|
122
|
+
content_root_key=self._settings.content_root_key,
|
|
129
123
|
match_headers=match_headers or self._settings.match_headers,
|
|
130
124
|
serializer=self.responses.serializer,
|
|
131
125
|
**kwargs,
|
|
@@ -139,6 +133,7 @@ class BaseCache:
|
|
|
139
133
|
key: Optional[str] = None,
|
|
140
134
|
request: Optional[AnyRequest] = None,
|
|
141
135
|
url: Optional[str] = None,
|
|
136
|
+
verify: bool = True,
|
|
142
137
|
):
|
|
143
138
|
"""Check if the specified request is cached
|
|
144
139
|
|
|
@@ -146,11 +141,12 @@ class BaseCache:
|
|
|
146
141
|
key: Check for a specific cache key
|
|
147
142
|
request: Check for a matching request, according to current request matching settings
|
|
148
143
|
url: Check for a matching GET request with the specified URL
|
|
144
|
+
verify: Check for requests with or without SSL verification
|
|
149
145
|
"""
|
|
150
146
|
if url:
|
|
151
147
|
request = Request('GET', url)
|
|
152
148
|
if request and not key:
|
|
153
|
-
key = self.create_key(request)
|
|
149
|
+
key = self.create_key(request, verify=verify)
|
|
154
150
|
return key in self.responses or key in self.redirects
|
|
155
151
|
|
|
156
152
|
def delete(
|
|
@@ -161,6 +157,7 @@ class BaseCache:
|
|
|
161
157
|
older_than: ExpirationTime = None,
|
|
162
158
|
requests: Optional[Iterable[AnyRequest]] = None,
|
|
163
159
|
urls: Optional[Iterable[str]] = None,
|
|
160
|
+
verify: bool = True,
|
|
164
161
|
):
|
|
165
162
|
"""Remove responses from the cache according one or more conditions.
|
|
166
163
|
|
|
@@ -171,12 +168,13 @@ class BaseCache:
|
|
|
171
168
|
older_than: Remove responses older than this value, relative to ``response.created_at``
|
|
172
169
|
requests: Remove matching responses, according to current request matching settings
|
|
173
170
|
urls: Remove matching GET requests for the specified URL(s)
|
|
171
|
+
verify: Set to ``False`` to remove responses without SSL verification
|
|
174
172
|
"""
|
|
175
173
|
delete_keys: List[str] = list(keys) if keys else []
|
|
176
174
|
if urls:
|
|
177
175
|
requests = list(requests or []) + [Request('GET', url).prepare() for url in urls]
|
|
178
176
|
if requests:
|
|
179
|
-
delete_keys += [self.create_key(request) for request in requests]
|
|
177
|
+
delete_keys += [self.create_key(request, verify=verify) for request in requests]
|
|
180
178
|
|
|
181
179
|
for response in self.filter(
|
|
182
180
|
valid=False, expired=expired, invalid=invalid, older_than=older_than
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
:classes-only:
|
|
5
5
|
:nosignatures:
|
|
6
6
|
"""
|
|
7
|
+
|
|
7
8
|
from typing import Iterable, Optional
|
|
8
9
|
|
|
9
10
|
import boto3
|
|
@@ -24,6 +25,7 @@ class DynamoDbCache(BaseCache):
|
|
|
24
25
|
|
|
25
26
|
Args:
|
|
26
27
|
table_name: DynamoDB table name
|
|
28
|
+
create_table: Whether or not to automatically create the dynamo backend table.
|
|
27
29
|
connection: :boto3:`DynamoDB Resource <services/dynamodb/service-resource/index.html#service-resource>`
|
|
28
30
|
object to use instead of creating a new one
|
|
29
31
|
ttl: Use DynamoDB TTL to automatically remove expired items
|
|
@@ -33,6 +35,7 @@ class DynamoDbCache(BaseCache):
|
|
|
33
35
|
def __init__(
|
|
34
36
|
self,
|
|
35
37
|
table_name: str = 'http_cache',
|
|
38
|
+
create_table: bool = True,
|
|
36
39
|
*,
|
|
37
40
|
ttl: bool = True,
|
|
38
41
|
connection: Optional[ServiceResource] = None,
|
|
@@ -44,6 +47,7 @@ class DynamoDbCache(BaseCache):
|
|
|
44
47
|
skwargs = {'serializer': serializer, **kwargs} if serializer else kwargs
|
|
45
48
|
self.responses = DynamoDbDict(
|
|
46
49
|
table_name,
|
|
50
|
+
create_table=create_table,
|
|
47
51
|
ttl=ttl,
|
|
48
52
|
connection=connection,
|
|
49
53
|
decode_content=decode_content,
|
|
@@ -58,6 +62,7 @@ class DynamoDbDict(BaseStorage):
|
|
|
58
62
|
|
|
59
63
|
Args:
|
|
60
64
|
table_name: DynamoDB table name
|
|
65
|
+
create_table: Whether or not to automatically create the dynamo backend table.
|
|
61
66
|
connection: :boto3:`DynamoDB Resource <services/dynamodb/service-resource/index.html#service-resource>`
|
|
62
67
|
object to use instead of creating a new one
|
|
63
68
|
ttl: Use DynamoDB TTL to automatically remove expired items
|
|
@@ -67,6 +72,7 @@ class DynamoDbDict(BaseStorage):
|
|
|
67
72
|
def __init__(
|
|
68
73
|
self,
|
|
69
74
|
table_name: str,
|
|
75
|
+
create_table: bool = True,
|
|
70
76
|
ttl: bool = True,
|
|
71
77
|
connection: Optional[ServiceResource] = None,
|
|
72
78
|
serializer: Optional[SerializerType] = dynamodb_document_serializer,
|
|
@@ -81,7 +87,8 @@ class DynamoDbDict(BaseStorage):
|
|
|
81
87
|
self.ttl = ttl
|
|
82
88
|
|
|
83
89
|
self._table = self.connection.Table(self.table_name)
|
|
84
|
-
|
|
90
|
+
if create_table:
|
|
91
|
+
self._create_table()
|
|
85
92
|
if ttl:
|
|
86
93
|
self._enable_ttl()
|
|
87
94
|
|