Skip to content

fix(idempotency): stop CachePersistenceLayer from emitting the Redis deprecation warning - #8625

Merged
leandrodamascena merged 1 commit into
aws-powertools:developfrom
MrNK2107:fix/cache-layer-deprecation-warning
Oct 22, 2026
Merged

leandrodamascena merged 1 commit into
aws-powertools:developfrom
MrNK2107:fix/cache-layer-deprecation-warning

Conversation

@MrNK2107

Copy link
Copy Markdown
Contributor

Issue number: closes #8574

Summary

Changes

CachePersistenceLayer, CacheConnection and CacheClientProtocol were TypeAliases of the deprecated Redis* classes, so they were the same object and @deprecated fired for both.

  • The implementation now lives under the Cache* names, without the decorator.
  • RedisCachePersistenceLayer, RedisConnection and RedisClientProtocol are thin @deprecated subclasses of them. Only the old names warn, and they still work anywhere a Cache* object is expected.
  • CachePersistenceLayer.__init__ builds a CacheConnection instead of a RedisConnection, so the new name no longer triggers the warning internally.
  • Fixed the RedisClientProtocol warning text, which named RedisPersistenceLayer / CacheProtocol.

I kept the implementation in redis.py rather than moving it into cache.py as the issue suggests. That keeps the diff small, keeps existing mock.patch("...persistence.redis.redis") targets working, and avoids conflicting with #8606, which edits the same methods. Happy to do the full move if you prefer.

One behaviour note: isinstance(CachePersistenceLayer(...), RedisCachePersistenceLayer) is now False, because the old name is the subclass. The reverse, isinstance(RedisCachePersistenceLayer(...), CachePersistenceLayer), is True.

Tests: new functional tests check that the Cache* names emit no DeprecationWarning, and that the Redis* names still warn with the right message and are instances of the Cache* classes. All idempotency tests pass.

User experience

Before:

CachePersistenceLayer(client=redis_client)
# DeprecationWarning: RedisCachePersistenceLayer will be removed in v4.0.0. Please use CachePersistenceLayer instead.

After: CachePersistenceLayer, CacheConnection and CacheClientProtocol no longer warn. RedisCachePersistenceLayer(...) still warns as before.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

…deprecation warning

CachePersistenceLayer, CacheConnection and CacheClientProtocol were TypeAliases
of the deprecated Redis* classes, so they were the same object and @deprecated
fired for both. The implementation now lives under the Cache* names and the
Redis* names are thin @deprecated subclasses, so only the old names warn.

Also fixes the RedisClientProtocol warning text, which named
RedisPersistenceLayer/CacheProtocol.

Fixes aws-powertools#8574
@MrNK2107
MrNK2107 requested a review from a team as a code owner October 18, 2026 19:10
@MrNK2107
MrNK2107 requested a review from hjgraca October 18, 2026 19:10
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 18, 2026
@boring-cyborg boring-cyborg Bot added the tests label Oct 18, 2026
@sonarqubecloud

Copy link
Copy Markdown

@leandrodamascena leandrodamascena added this to the 3.38.0 milestone Oct 19, 2026

@leandrodamascena leandrodamascena left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @MrNK2107! I ran the suite with -W always: the Cache* names are silent, the Redis* names still warn with the corrected text, and the old class still works end to end with custom attribute names. Keeping the implementation in redis.py was the right call for the mock targets, and I test-merged this with #8606 on the same file, no conflicts. The isinstance note is fair and the only thing anyone could notice.

Approving now. This goes out in 3.38.0, so it will sit here a bit before I merge. No need to rebase or touch anything, I'll take care of it and you'll get the credit in the release notes. Thank you!

@leandrodamascena
leandrodamascena merged commit 2af58c0 into aws-powertools:develop Oct 22, 2026
15 checks passed
@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.93%. Comparing base (0f64f28) to head (acbea71).
⚠️ Report is 13 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8625   +/-   ##
========================================
  Coverage    96.93%   96.93%           
========================================
  Files          318      318           
  Lines        16031    16031           
  Branches      1423     1426    +3     
========================================
  Hits         15540    15540           
  Misses         349      349           
  Partials       142      142           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: CachePersistenceLayer raises the deprecation warning that tells you to use CachePersistenceLayer

2 participants