Problem
counter_value() (types.py) parses int(entry.content) without checking fingerprint == COUNTER_FINGERPRINT. On the Memory backend (and the base fallback), increment() on a cached response whose body is 42 returns 43 and overwrites it. Redis and Memcached raise CacheXError, as the base docstring documents.
set(k, counter_entry(5)) followed by increment(k) works on Memory but raises on Redis/Memcached, which store the entry as a JSON document.
codec._as_counter uses int(raw), which accepts whitespace and underscores (b" 7 ", b"1_0").
Proposal
Require the counter fingerprint in counter_value, use a strict ^-?\d+$ check in the codec, and optionally store counter_entry values as bare integers on Redis/Memcached.
Not breaking beyond these edge cases.
Problem
counter_value()(types.py) parsesint(entry.content)without checkingfingerprint == COUNTER_FINGERPRINT. On the Memory backend (and the base fallback),increment()on a cached response whose body is42returns 43 and overwrites it. Redis and Memcached raiseCacheXError, as the base docstring documents.set(k, counter_entry(5))followed byincrement(k)works on Memory but raises on Redis/Memcached, which store the entry as a JSON document.codec._as_counterusesint(raw), which accepts whitespace and underscores (b" 7 ",b"1_0").Proposal
Require the counter fingerprint in
counter_value, use a strict^-?\d+$check in the codec, and optionally storecounter_entryvalues as bare integers on Redis/Memcached.Not breaking beyond these edge cases.