Skip to content

refactor(manager): encode the JSON content once in CacheManager._encode - #210

Merged
allen0099 merged 1 commit into
masterfrom
refactor/cache-manager-encode-once
Sep 26, 2026
Merged

allen0099 merged 1 commit into
masterfrom
refactor/cache-manager-encode-once

Conversation

@allen0099

Copy link
Copy Markdown
Owner

Closes #183

Summary

CacheManager._encode encoded the json.dumps result twice: once to hash it for the fingerprint, and once for the stored content. It now encodes once and hashes the same bytes. str.encode() already defaults to UTF-8, so the fingerprint and the content are byte-for-byte the same as before.

Tests

  • No new test. Behaviour is unchanged, and the existing CacheManager tests cover _encode.
  • ruff, mypy --strict, full suite against live Redis and Memcached (CACHEX_REQUIRE_LIVE_SERVERS=1): 861 passed.

CHANGELOG entry

None (internal refactor).

_encode encoded the JSON string once for the fingerprint and again for
the stored content. Encode it once and hash the same bytes. str.encode()
already defaults to UTF-8, so the stored entry is unchanged.

Closes #183
@allen0099 allen0099 added this to the 0.3.8 milestone Sep 26, 2026
@allen0099 allen0099 added enhancement New feature or request cache-manager Application-level CacheManager labels Sep 26, 2026
@allen0099
allen0099 merged commit 2f5f6e0 into master Sep 26, 2026
11 checks passed
@allen0099
allen0099 deleted the refactor/cache-manager-encode-once branch September 26, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cache-manager Application-level CacheManager enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CacheManager._encode encodes the JSON string twice

1 participant