Skip to content
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

Disable decorators cache per-call #404

Merged
merged 3 commits into from
May 27, 2018
Merged

Disable decorators cache per-call #404

merged 3 commits into from
May 27, 2018

Conversation

jcugat
Copy link
Contributor

@jcugat jcugat commented May 26, 2018

MR for #386

Not convinced about the naming (too long?), I'm open to suggestions.

Regarding the documentation, I am not sure where to put it since the docstring in the decorator is only for parameters for the decorator itself, and not calls to the decorator.

@codecov
Copy link

codecov bot commented May 26, 2018

Codecov Report

Merging #404 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #404      +/-   ##
==========================================
+ Coverage   99.76%   99.77%   +<.01%     
==========================================
  Files           9        9              
  Lines         866      871       +5     
  Branches       91       95       +4     
==========================================
+ Hits          864      869       +5     
  Misses          2        2
Impacted Files Coverage Δ
aiocache/decorators.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 48cab91...44026b8. Read the comment docs.

Copy link
Member

@argaen argaen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one! only minor modifications

@@ -72,14 +72,19 @@ def __call__(self, f):
return wrapper

async def decorator(self, f, *args, **kwargs):
disable_read = kwargs.pop('aiocache_disable_read', False)
disable_write = kwargs.pop('aiocache_disable_write', False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put explicitly in the function signature please

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, add docs about those two new parameters in the class docstring or in decorators.rst

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -94,6 +94,37 @@ def test_get_cache_key_with_key_builder(self, decorator):
assert decorator.cache.set.call_count == 0
assert stub.call_count == 0

@pytest.mark.asyncio
async def test_disable_read(self, decorator, decorator_call):
decorator.cache.get = CoroutineMock(return_value=1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this if its not being called?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably from copy&pasting, removed

@@ -434,6 +465,38 @@ def test_get_cache_keys_with_key_builder(self, decorator):
with pytest.raises(Exception):
assert await decorator_call(keys=[])

@pytest.mark.asyncio
async def test_disable_read(self, decorator, decorator_call):
decorator.cache.multi_get = CoroutineMock(return_value=[1, 2])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, not needed because its not being called?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@argaen
Copy link
Member

argaen commented May 27, 2018

Not convinced about the naming (too long?), I'm open to suggestions.

Yeah I thought the same... Maybe cache_read and cache_write and set them to True by default?

@argaen argaen merged commit 6d95ea9 into aio-libs:master May 27, 2018
@underyx underyx mentioned this pull request Jun 14, 2018
@jcugat jcugat deleted the feature/disable_decorators branch June 15, 2019 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants