Skip to content

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
@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