SebastiaanZ / async-rediscache

An easy-to-use asynchronous redis-backed caching utility
18 stars 3 forks source link

Migrate To aioredis v2 #18

Closed HassanAbouelela closed 2 years ago

HassanAbouelela commented 2 years ago

This PR migrates the aioredis version required for the library to ~= 2, which introduces a lot of breaking changes. I've documented below what can best be described as a changelog/migration guide. There is also a version bump from 0.2 to 1.0 as aioredis 2 is going to be incompatible with projects which use the old version.

Removed:

Changed:

Added

Connection Pattern Changes

This is where the bulk of the changes lie. aioredis 2.0 abstracts away all the logic for managing the connection and underlying pool (in fact it's nearly impossible to do now, as each pool connection is supposed to be tied directly to a single instruction). This means that all users need to factor out any pool accessing, and instead replace those blocks with direct calls to the client object.

Migration Guide

To migrate from 0.2 to 1.0.0, you need to do the following:

  1. Add the URL parameter when initializing the session
  2. Remove all usages of namespace locking if they still exist
  3. Make changes according to the API changes listed above
  4. If you use aioredis directly, follow the migration guide here. Unfortunately, the guide is incomplete, and the changelog is almost non-existant. This shouldn't be too difficult to overcome if you have a good static analysis tool however. Here is a (incomplete) list of some undocumented API changes which you might find useful:

    • brpoplpush and rpoplpush no longer take sourcekey and destkey, but src and dst
    • hmset_dict has been removed. You can use hset (or hmset, but that's deprecated) with the mapping kwarg instead
    • Exceptions have been rewritten, and have very poor documentation

    I have not noticed any other undocumented changes but YMMV.

coveralls commented 2 years ago

Pull Request Test Coverage Report for Build 2698158605


Changes Missing Coverage Covered Lines Changed/Added Lines %
async_rediscache/session.py 16 17 94.12%
<!-- Total: 135 136 99.26% -->
Totals Coverage Status
Change from base Build 652299207: 3.7%
Covered Lines: 803
Relevant Lines: 806

💛 - Coveralls
SebastiaanZ commented 2 years ago

Thank you, I'll have a look at the PR.

HassanAbouelela commented 2 years ago

Hey, I've gone through the PR again now and I'm more or less happy with where it was. I was hoping to get a few more reviews and push out a full release soon, but a more realistic approach might be to release this as a beta or RC within the next week, and work on fixing any reported issues.

If that's alright, I'm planning on doing that on Tuesday or so.

onerandomusername commented 2 years ago

Given that the version was 0.2, this is fine to be 0.3 its widely accepted that projects that haven't reached a 1.0 release can be breaking with each minor release.

HassanAbouelela commented 2 years ago

The bump to 1.0 was to follow the deprecation timeline for the lock decorator. Not that it should matter, this repo is pretty stable and I think a 1.0 should be fine.