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

Decode cache data to the correct endpoint type #131

Merged
merged 1 commit into from
May 9, 2023

Conversation

mjpieters
Copy link
Collaborator

Use the return annotation to decode cached data to the correct type.
This follows the same logic FastAPI uses to JSON request bodies.

For the PickleCoder, this is a no-op as pickle already stores type
information in the serialised data.

Fixes #120

Use the return annotation to decode cached data to the correct type.
This follows the same logic FastAPI uses to JSON request bodies.

For the PickleCoder, this is a no-op as pickle already stores type
information in the serialised data.
@long2ice long2ice merged commit 1ded0ed into long2ice:main May 9, 2023
@long2ice
Copy link
Owner

long2ice commented May 9, 2023

Thanks!

@mjpieters
Copy link
Collaborator Author

One concern I do think I'd like to address still is that of performance. Creating a Pydantic field for a return type is fast, but not so fast that caching the result won't help. Given that there are a finite number of endpoints that you want to apply caching to, but an infinite number of cache hits, I think a type -> field cache would help here. I'll do some testing.

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.

[Bug] When Dataclass is saved in InMemory, dict is returned.
2 participants