aiocache
aiocache copied to clipboard
JsonSerializer & SimpleMemoryBackend: get after increment raises TypeError
- int type is added into dict in SimpleMemoryBackend.increment
- JsonSerializer.loads tries to load int value.
As result: TypeError the JSON object must be str, bytes or bytearray, not int
pull request with fix: https://github.com/argaen/aiocache/pull/483
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)
.