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

JsonSerializer & SimpleMemoryBackend: get after increment raises TypeError #482

Open
Sergei-Rudenkov opened this issue Apr 10, 2020 · 2 comments

Comments

@Sergei-Rudenkov
Copy link

Sergei-Rudenkov commented Apr 10, 2020

As result: TypeError the JSON object must be str, bytes or bytearray, not int

Sergei-Rudenkov pushed a commit to Sergei-Rudenkov/aiocache that referenced this issue Apr 10, 2020
@Sergei-Rudenkov
Copy link
Author

pull request with fix: #483

Sergei-Rudenkov pushed a commit to Sergei-Rudenkov/aiocache that referenced this issue Apr 13, 2020
@argaen argaen added this to the 0.12.0 milestone Oct 15, 2020
@Dreamsorcerer
Copy link
Member

Problem is that increment seems to be an operation that should be done on the backend efficiently. This requires storing the value as an int in the backend.

If you are using a serialiser that changes the values (e.g. JSON converts to str stored in the backend), then this obviously won't work.

We should put a warning or something in the docs, and maybe see if we can disable the increment() method if an inappropriate serialiser is being used (or maybe a fallback method could be used which just does set(key, get(key) + 1).

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

No branches or pull requests

3 participants