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

feat: adds extra cache key components support #62

Merged
merged 3 commits into from
Dec 15, 2023

Conversation

pySilver
Copy link
Contributor

I was surprised to find my own ticket here haha :)

This feature allows to bind our memoized functions with external state. Extra argument can be anything json-serializable or even callable.

@cache_memoize(60, extra=('foo', obj.pk, foo.last_updated_at))
def foo(*args, **kwargs):
    return 42

@cache_memoize(100, extra={"version": 2})
def callmeonce(arg1):
    print(arg1)

@cache_memoize(100, extra=100500)
def callmeonce(arg1):
    print(arg1)

@cache_memoize(100, extra=lambda user: user.is_staff)
def callmeonce(user):
    print(arg1)

Originally requested at #49 (solves #35 )

@pySilver
Copy link
Contributor Author

pySilver commented Aug 4, 2023

Can we merge it?

@pySilver
Copy link
Contributor Author

@peterbe :) kind reminder about PR. It contains tests and it is fully BC.

@peterbe
Copy link
Owner

peterbe commented Sep 26, 2023

@peterbe :) kind reminder about PR. It contains tests and it is fully BC.

Sure! Can you merge in latest main and that should start the CI suites.

@pySilver
Copy link
Contributor Author

@peterbe Oh I've missed your reply. I've just synced master branch with this PR

@peterbe peterbe merged commit 6217d9c into peterbe:master Dec 15, 2023
4 checks passed
@pySilver pySilver deleted the feat-extra-keys branch December 15, 2023 18:46
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