-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create a weak_cache in Injector #184
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #184 +/- ##
==========================================
+ Coverage 86.83% 86.90% +0.07%
==========================================
Files 15 15
Lines 896 901 +5
==========================================
+ Hits 778 783 +5
Misses 118 118
|
I don’t fully understand the motivation behind this. When do providers need this? |
It's quite similar to having the serialized cache turned on via class SomePage(BasePage):
response: AnyResponse
http_response: HttpResponse Previously, the example above, results in |
Currently,
SCRAPY_POET_CACHE
can be set toTrue
to allow scrapy-poet to save instances created by providers locally. By default, this is turned off.I'm proposing to introduce an
Injector.weak_cache
that would have its instances stored in memory and be removed when the correspondingRequest
instance is no longer available. By default, this is turned on. The motivation for this is to allow sharing of instances between providers by default without the risk of accumulating large number of instances locally which can result in running out of disk space.This also means that the weakref cache mechanism in ZyteApiProvider (code ref) can be removed as it can use this new
.weak_cache
directly from the Injector.Other related PRs: