Open
Conversation
36a0080 to
46bd1b3
Compare
46bd1b3 to
92e54b4
Compare
92e54b4 to
6f348a4
Compare
6f348a4 to
1ac985b
Compare
1ac985b to
78b9e69
Compare
78b9e69 to
7ee0264
Compare
7ee0264 to
f0aef47
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
==0.6.4→==1.3.1Warning
Some dependencies could not be looked up. Check the Dependency Dashboard for more information.
Release Notes
requests-cache/requests-cache (requests_cache)
v1.3.1Compare Source
Varyread_onlymodev1.3.0Compare Source
💾 Serialization:
serializer='json'will no longer automatically useultrajsonif installed; it must be specified explicitlybsoncodec; please installpymongoto use BSON serialization[bson]package extra to prevent accidentally installing it in the same environment aspymongo.bsonfile extension by defaultorjsonas a JSON serializerjson_serializer,ujson_serializer, andorjson_serializer[json]package extra due to multiple supported JSON librariesdecode_contentto be set to different values across multiple sessions in use at the same time💾 Backends:
requests_cache.backends.filesystem.LRUFileDictclass to optionally limit the size of the filesystem cache. Enabled withmax_cache_bytesargument.SCANandHSCANinstead ofKEYS,HKEYS, andHGETALLcreate_tableofDynamoDBCacheto control if the class attempts to create the table in DynamoDB or not.connectionparameter to allow passing an existingMongoClientobject🕗 Expiration & headers:
Vary: Cookie⚙️ Session settings:
autocloseoption to close backend connections when the session is closedread_onlyoption to read existing cached responses, but not write any new responses to the cacheℹ️ Cache convenience methods:
verifyparameter toBaseCache.contains()anddelete()to handle requests made with SSL verification disabled🧩 Compatibility and packaging:
🪲 Bugfixes:
content_root_keysetting to target a sub-tree innormalize_json_body, so only listed fields under that key are ignored in cache keyssqlite3.InterfaceError: bad parameter or other API misusewith concurrent SQLite usage in python 3.12+requests-cache <= 1.1stale_if_errorduring revalidation requestsinstall_cache()expire_afteris set toDO_NOT_CACHEcache_nameand a backend instance (database names, file paths, etc. cannot be reliably updated after initialization)Content-LengthandTransfer-Encoding1.2.1 (2024-06-18)
🪲 Bugfixes:
normalize_headersnot accepting header values in bytesCachedResponse.expires_unixpropertydecode_content=Truewhen the root element is an empty list or objectresponseslibrary to be compatible withrequests2.32v1.2.1Compare Source
🪲 Bugfixes:
normalize_headersnot accepting header values in bytesCachedResponse.expires_unixpropertydecode_content=Truewhen the root element is an empty list or objectresponseslibrary to be compatible withrequests2.32v1.2.0Compare Source
CachedSessionandBaseCache🕗 Expiration & headers:
X-HTTP-Method-Overrideand other headers that can override request method⚙️ Session methods:
CachedSession.wrap()classmethod to add caching to an existingrequests.Sessionobject💾 SQLite Backend:
vacuumparameter toSQLiteCache.delete()to optionally skip vacuuming after deletion (enabled by default to free up disk space)SQLiteCache.delete()when deleting a single key🧩 Compatibility:
decode_content=True(root element with any type)🪲 Bugfixes:
IncompleteReaderror that could sometimes occur with streaming requests due to mismatch withContent-LengthheaderCachedHTTPResponse._request_urlproperty for compatibility with urllib3verifyparam, cache the response under the same key asverify=Trueapplication/vnd.api+json) during request normalization and serialization1.1.1 (2023-11-18)
v1.1.1Compare Source
v1.1.0Compare Source
⚙️ Session settings:
urls_expire_after💾 SQLite Backend:
busy_timeoutargument (see SQLite docs for details)wal=True), default to 'normal' synchronous mode instead of 'full'OperationalError: database is lockedin multithreaded SQLite usage during bulk delete operations🪲 Bugfixes:
decode_content=Truewhen the root element is a listBaseCache.recreate_keys()to normalize response bodies withb'None'BaseCache.contains()for multipart POST requestsCachedResponse.historynot being fully deserialized on python<=3.8Varyand redirectsCachedResponse.urlso it always matches the original request URL1.0.1 (2023-03-24)
Cache-Control: must-revalidateandno-cacheresponse headers withcache_control=Falsev1.0.1Compare Source
Cache-Control: must-revalidateandno-cacheresponse headers withcache_control=Falsev1.0.0Compare Source
See all unreleased issues and PRs
🕗 Expiration & headers:
Cache-Control: min-freshCache-Control: max-staleCache-Control: only-if-cachedCache-Control: stale-if-errorCache-Control: stale-while-errorVaryCache-Control: no-cacherequest or response headerCache-Control: max-age=0, must-revalidateresponse headersCachedResponse.revalidatedto indicate if a cached response was revalidated forthe current request
⚙️ Session settings:
CachedSession.settingsalways_revalidatesession setting to always revalidate before using a cached response (if a validator is available).only_if_cachedsession setting to return only cached results without sending real requestsstale_while_revalidatesession setting to return a stale response initially, while a non-blocking request is sent to refresh the responsestale_if_errorpartially consistent withCache-Control: stale-if-error: Add support for time values (int, timedelta, etc.) in addition toTrue/False⚙️ Request settings:
only_if_cachedoption toCachedSession.request()andsend()to return only cached results without sending real requestsrefreshoption toCachedSession.request()andsend()to revalidate with the server before using a cached responseforce_refreshoption toCachedSession.request()andsend()to awlays make and cache a new request regardless of existing cache contentsexpire_after=0consistent withCache-Control: max-age=0: if the response has a validator, save it to the cache but revalidate on use.requests_cache.DO_NOT_CACHEmay be used to completely disable caching for a request💾 Backends:
len()) now uses a fast table estimate instead of a full scanMay be disabled with
decode_content=False.May be disabled with
decode_content=False.May be disabled with
decode_content=False.ttl_offsetargument to add a delay between cache expiration and deletiondelete()count()method to count responses, with option to exclude expired responses (performs a fast indexed count instead of slower in-memory filtering)size()method to get estimated size of the database (including in-memory databases)sorted()method with sorting and other query optionswalparameter to enable write-ahead loggingCachedSessionis used as a contextmanager, or ifCachedSession.close()is calledallowable_methods(previously only skipped write)some default recommended values for
ignored_parameters, to avoid accidentally storing commoncredentials in the cache. This will have no effect if
ignored_parametersis already set.ignored_parameters(e.g., for a request sent both with and without authentication)
a=1vs?a=1&a=2)ℹ️ Convenience methods:
expiredandinvalidarguments toBaseCache.delete()(to replaceremove_expired_responses())urlsandrequestsarguments toBaseCache.delete()(to replacedelete_url())older_thanargument toBaseCache.delete()to delete responses older than a given valuerequestsargument toBaseCache.delete()to delete responses matching the given requestsBaseCache.contains()method to check for cached requests either by key or byrequests.Requestobjecturlargument toBaseCache.contains()method (to replacehas_url())BaseCache.filter()method to get responses from the cache with various filtersBaseCache.reset_expiration()method to reset expiration for existing responsesBaseCache.recreate_keys()method to recreate cache keys for all previously cached responses(e.g., to preserve cache data after an update that changes request matching behavior)
BaseCache.urlsinto a method that takes optional filter params, and returns sorted unique URLsℹ️ Response attributes and type hints:
OriginalResponsetype, which adds type hints torequests.Responseobjects for extra attributes added by requests-cache:cache_keycreated_atexpiresfrom_cacheis_expiredrevalidatedOriginalResponse.cache_keyandexpireswill be populated for any new response that was written to the cacheCachedSession.get(),head(), etc.)CachedResponse.cache_keyattribute for responses read from lower-level storage methods(
items(),values(), etc.)🧩 Compatibility fixes:
AttributeErrordue to undetected imports when requests-cache is bundled in a PyInstaller packageRedisCachefor redis-py 4.2 and python <=3.8MongoCachefor pymongo 4.1 and python <=3.8🪲 Bugfixes:
install_cache()OperationalError: database is lockedin SQLite backendCachedResponse.created_attimestampCachedRequest.path_urlproperty for compatibility withRequestEncodingMixinAttributeErrordue to undetected imports when requests-cache is bundled in a PyInstaller packageAttributeErrorwhen attempting to unpickle aCachedSessionobject, and instead disable pickling by raising aNotImplementedErrorstale_if_errorif an error response code is added toallowable_codes📦 Dependencies:
appdirswithplatformdirsThe following methods are deprecated, and will be removed in 1.2. The recommended
replacements are listed below. If this causes problems for you, please open an issue to discuss.
CachedSession.remove_expired_responses():BaseCache.delete(expired=True)BaseCache.remove_expired_responses():BaseCache.delete(expired=True)BaseCache.delete_url():BaseCache.delete(urls=[...])BaseCache.delete_urls():BaseCache.delete(urls=[...])BaseCache.has_key():BaseCache.contains()BaseCache.has_url():BaseCache.contains(url=...)BaseCache.keys():BaseCache.responses.keys()(for all keys), orBaseCache.filter()(for filtering options)BaseCache.values():BaseCache.responses.values()(for all values), orBaseCache.filter()(for filtering options)BaseCache.response_count():len(BaseCache.responses)(for all responses), orBaseCache.filter()(for filtering options)CachedSession.settings. Previously, some settings could be modified by setting them on eitherCachedSessionorBaseCache. In some cases this could silently fail or otherwise have undefined behavior.BaseCache.urlshas been replaced with a method that returns a list of URLs.Minor breaking changes:
The following changes only affect advanced or undocumented usage, and are not expected to impact most users:
match_headersandignored_parametersmust be passed toCachedSession. Previously, these could also be passed to aBaseCacheinstance.CachedSessionbackendargument must be either an instance or string alias. Previously it would also accept a backend class.BaseStoragesubclasses have been removed, and merged into their respective parent classes. This includesSQLitePickleDict,MongoPickleDict, andGridFSPickleDict.BaseStoragesubclasses now have aserializerattribute, which will be unused if set toNone.cache_controlmodule (added in0.7) has been split up into multiple modules in a newpolicysubpackage0.9.8 (2023-01-13)
DeprecationWarningraised byBaseCache.urlsBaseCache.deleteBackport fixes from 1.0:
omit_if_default0.9.7 (2022-10-26)
Backport compatibility fixes from 1.0:
AttributeErrordue to undetected imports when requests-cache is bundled in a PyInstaller packageAttributeErrorwhen attempting to unpickle aCachedSessionobject, and instead disable pickling by raising aNotImplementedErrorAdd the following for forwards-compatibility with 1.0:
DeprecationWarningsto give an earlier notice for methods deprecated (not removed) in 1.0requests_cache.policysubpackage (will replacerequests_cache.cache_controlmodule)BaseCache.contains()BaseCache.delete()BaseCache.filter()CachedSession.settings0.9.6 (2022-08-24)
Backport fixes from 1.0:
BaseCache.__str__()0.9.5 (2022-06-29)
Backport fixes from 1.0:
install_cache()CachedRequest.path_urlproperty0.9.4 (2022-04-22)
Backport fixes from 1.0:
RedisCachefor redis-py 4.2 and python <=3.8MongoCachefor pymongo 4.1 and python <=3.80.9.3 (2022-02-22)
bsonand standalonebsoncodec.CorruptGridFileerror in GridFS backend~/...) for SQLite and filesystem backendsbefore it is read by a different thread
0.9.2 (2022-02-15)
paramsas a positional argument toCachedSession.request()CachedSession.request(..., expire_after=-1)0.9.1 (2022-01-15)
ForwardReftypes during deserialization)v0.9.8Compare Source
DeprecationWarningraised byBaseCache.urlsBaseCache.deleteBackport fixes from 1.0:
omit_if_defaultv0.9.7Compare Source
Backport compatibility fixes from 1.0:
AttributeErrordue to undetected imports when requests-cache is bundled in a PyInstaller packageAttributeErrorwhen attempting to unpickle aCachedSessionobject, and instead disable pickling by raising aNotImplementedErrorAdd the following for forwards-compatibility with 1.0:
DeprecationWarningsto give an earlier notice for methods deprecated (not removed) in 1.0requests_cache.policysubpackage (will replacerequests_cache.cache_controlmodule)BaseCache.contains()BaseCache.delete()BaseCache.filter()CachedSession.settingsv0.9.6Compare Source
Backport fixes from 1.0:
BaseCache.__str__()v0.9.5Compare Source
Backport fixes from 1.0:
install_cache()CachedRequest.path_urlpropertyv0.9.4Compare Source
Backport fixes from 1.0:
RedisCachefor redis-py 4.2 and python <=3.8MongoCachefor pymongo 4.1 and python <=3.8v0.9.3Compare Source
bsonand standalonebsoncodec.CorruptGridFileerror in GridFS backend~/...) for SQLite and filesystem backendsbefore it is read by a different thread
v0.9.2Compare Source
paramsas a positional argument toCachedSession.request()CachedSession.request(..., expire_after=-1)v0.9.1Compare Source
ForwardReftypes during deserialization)v0.9.0Compare Source
See all issues and PRs for 0.9
🕗 Expiration & headers:
Cache-Controlrequest headers by defaultCache-Control: immutableCache-Control: max-age=0andExpires: 0304 Not Modifiedresponse is receivedexpire_afterparam forCachedSession.send()💾 Backends:
🚀 Performance:
CachedSession.request()andCachedSession.send()🪲 Bugfixes:
BaseCachekeyword arguments passed along with a backend instancecache_control=Trueis used with anexpire_aftervalueCachedResponseserialization behavior when using stdlibpicklein a custom serializer0.8.1 (2021-09-15)
ignored_parametersfromCachedResponse.url(if used for credentials or other sensitive info)DbDict, etc. so fully qualified imports don't breakv0.8.1Compare Source
ignored_parametersfromCachedResponse.url(if used for credentials or other sensitive info)DbDict, etc. so fully qualified imports don't breakv0.8.0Compare Source
See all issues and PRs for 0.8
🕗 Expiration & headers:
ETag+If-None-MatchheadersLast-Modified+If-Modified-Sinceheaders304 Not Modifiedresponses💾 Backends:
FileCache.cache_dirwrapper propertyFileCache.paths()methoduse_cache_diroption to use platform-specific user cache directorypathlib.Pathobjects for all file pathsSQLiteCache.db_pathwrapper propertyuse_memoryoption and support for in-memory databasesuse_cache_diroption to use platform-specific user cache directorypathlib.Pathobjects for all file paths🚀 Performance:
cattrsby default for optimized serializationcreate_key()to optionally accept parameters forrequests.Requestinstead of a request objectmatch_headersto optionally accept a list of specific headers to matchkey_fnparameterℹ️ Cache convenience methods:
BaseCache.update()method as a shortcut for exporting to a different cache instanceBaseCache.has_url()anddelete_url()to optionally take parameters forrequests.Requestinstead of just a URL📦 Dependencies:
appdirsas a dependency for easier cross-platform usage of user cache directoriescattrsfrom optional to required dependencyitsdangerousfrom required to optional (but recommended) dependencyrequests2.22+ andurllib31.25.5+The following changes are meant to make certain behaviors more obvious for new users, without breaking existing usage:
Cache-Control: stale-if-error, renameold_data_on_errortostale_if_errorinclude_get_headerstomatch_headersbackends.sqlite.Db*->SQLiteCache,SQLiteDict,SQLitePickleDictcoremoduleBaseCache.remove_old_entries()method0.7.5 (2021-09-15)
redirects.sqlitewhen using filesystem backendredirects.sqlitewould get included in response paths with filesystem backend0.7.4 (2021-08-16)
Expiresheaders not getting converted to UTC0.7.3 (2021-08-10)
DbCache.clear()to succeed even if the database is corruptedDbDict.bulk_delete()to split the operation into multiple statements to support deleting more items than SQLite's variable limit (999).json,.yaml,.pkl, etc.) by default; can be overridden or disabled with theextensionparameter.BaseCache.delete_urls()method to bulk delete multiple responses from the cache based onrequest URL
0.7.2 (2021-07-21)
Response.next(to get the next request in a redirect chain) when 302 responses are cached directlyCachedResponse.cache_keyattributeCachedResponsea non-slotted class to allow client code to set arbitrary attributes on it0.7.1 (2021-07-09)
v0.7.5Compare Source
redirects.sqlitewhen using filesystem backendredirects.sqlitewould get included in response paths with filesystem backendv0.7.4Compare Source
Expiresheaders not getting converted to UTCv0.7.3Compare Source
DbCache.clear()to succeed even if the database is corruptedDbDict.bulk_delete()to split the operation into multiple statements to support deleting more items than SQLite's variable limit (999).json,.yaml,.pkl, etc.) by default; can be overridden or disabled with theextensionparameter.BaseCache.delete_urls()method to bulk delete multiple responses from the cache based onrequest URL
v0.7.2Compare Source
Response.next(to get the next request in a redirect chain) when 302 responses are cached directlyCachedResponse.cache_keyattributeCachedResponsea non-slotted class to allow client code to set arbitrary attributes on itv0.7.1Compare Source
v0.7.0Compare Source
See all issues and PRs for 0.7
🕗 Expiration & headers:
Cache-Control: max-ageCache-Control: no-cacheCache-Control: no-storeCache-Control: max-ageCache-Control: no-storeExpirescache_controloption toCachedSessionto enable setting expiration with cache headersexpire_afterparametersexpire_after=0💾 Backends:
DynamoDbDict.__iter__to return keys instead of valuesboto3.resourceCollection.find_and_modify()pymongo.MongoClientredis.Redisuse_tempoption to store files in a temp directorysqlite3.connect💾 Serialization:
cattrsultrajsonignored_parametersto also exclude ignored request params, body params, or headers from cached response data (to avoid storing API keys or other credentials)old_data_on_erroroption to also handle error response codesold_data_on_erroris setℹ️ Convenience methods:
BaseCache.save_response()BaseCache.keys()andvalues()methodsBaseCache.response_count()method to get an accurate count of responses (excluding invalid and expired)str(CachedResponse)CachedSession,CachedResponse, andBaseCacheBaseCache.urlsto only skip invalid responses, not delete them (for better performance)📦 Dependencies:
requestsversion of2.17attrsas a dependency for improved serialization modelscattrsas an optional dependencypip install):requests-cache[all](to install everything)requests-cache[bson]requests-cache[json]requests-cache[dynamodb]requests-cache[mongodb]requests-cache[redis]📦 Compatibility and packaging:
requests 2.17and2.18requests0.6.4 (2021-06-04)
filter_fn()would get called onresponse.requestinstead ofresponse0.6.3 (2021-04-21)
include_get_headersdecode_contentparameter forCachedResponse.raw.read()Collection.count()withestimated_document_count()0.6.2 (2021-04-14)
0.6.1 (2021-04-13)
BaseCache.urlsBaseCache.remove_old_entries()back, as an alias with a DeprecationWarningaws_access_key_idandaws_secret_access_keykwargs toDynamoDbDictGridFSPickleDict.__delitem__to raise a KeyError for missing itemslogging.infostatements to debug levelfind_packages()Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.