Found during the docs audit (#359). The docs now describe the per-backend ranges; the behaviour at the edge still differs.
| Backend |
Incrementing past the range |
| Redis |
raises a raw redis.exceptions.ResponseError ("increment or decrement would overflow"). backends/redis.py:435-439 only converts the "not an integer" error to CacheXError |
| Memcached |
wraps around silently: counter_entry(2**64 - 1) incremented by 1 returns 0 |
| Memory |
grows past 64 bits without limit |
validate_delta already limits delta to signed 64-bit, but the resulting value is unchecked.
Proposal
Make overflow one documented behaviour on every backend, most likely CacheXError (Redis: also convert the overflow ResponseError; Memcached: detect the wrap, e.g. compare against the previous value, or document unsigned 64-bit as its range and reject values that would wrap; Memory: bound to signed 64-bit). Decide whether this is a fix for a patch release or a behaviour change for 0.4.0. Tests per backend.
Found during the docs audit (#359). The docs now describe the per-backend ranges; the behaviour at the edge still differs.
redis.exceptions.ResponseError("increment or decrement would overflow").backends/redis.py:435-439only converts the "not an integer" error toCacheXErrorcounter_entry(2**64 - 1)incremented by 1 returns0validate_deltaalready limitsdeltato signed 64-bit, but the resulting value is unchecked.Proposal
Make overflow one documented behaviour on every backend, most likely
CacheXError(Redis: also convert the overflowResponseError; Memcached: detect the wrap, e.g. compare against the previous value, or document unsigned 64-bit as its range and reject values that would wrap; Memory: bound to signed 64-bit). Decide whether this is a fix for a patch release or a behaviour change for 0.4.0. Tests per backend.