Giter Club home page Giter Club logo

redis-py's People

Contributors

burak-upstash avatar cahidarda avatar enesakar avatar mdumandag avatar tudorzgimbau avatar ytkimirti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

ytkimirti

redis-py's Issues

Python version

  • The minimum supported Python version of 3.11 is too recent. Most of the ecosystem have support for Python 3.8 and even for 3.7. Given that we are very close to the end-of-life of Python 3.7, I believe we can set to minimum Python version to 3.8.

Some comments on the current state of the library

Here are my initial views on the current state of the library

  • I believe the name of the library should be changed from upstash_py to upstash_redis. The py suffix does not add any value, and we have other products, so giving a more descriptive name with redis suffix would be better.
  • The minimum supported Python version of 3.11 is too recent. Most of the ecosystem have support for Python 3.8 and even for 3.7. Given that we are very close to the end-of-life of Python 3.7, I believe we can set to minimum Python version to 3.8.
  • Asyncio is not dominant yet. Providing an API only for it might hurt the adoption of the library. I think we should do what most of the other libraries do, and provide sync + async APIs on the same package, and the default implementation should have sync APIs: Basically, upstash_redis.Redis and upstash_redis.aio.Redis, which provides the sync and async versions of the same API.
  • The implementation of the library currently deviates from the Redis command definitions on the parameter names. For example, we currently have the following API:
        async def set(
            self,
            key: str,
            value: Any,
            nx: bool = False,
            xx: bool = False,
            get: bool = False,
            seconds: int | None = None,
            milliseconds: int | None = None,
            unix_time_seconds: int | None = None,
            unix_time_milliseconds: int | None = None,
            keep_ttl: bool = False,
        ) -> str | None: ...
    However, the command definition on the Redis is as follows:
    SET key value [NX | XX] [GET] [EX seconds | PX milliseconds |
      EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL]
    
    IMO we should follow the command definitions. I gave an example for this specific command, but there might be other deviations.
  • The current test suite is not enough. There are lots of commands which we don't have even a single test for. And, in my local environment, most of the tests are failing. We should fix this, and improve the test suite.
  • Current type hints have some problems. Running mypy shows 33 errors. In the strict mode, the error count is currently at 219.
  • We don't have any CI/CD set. We should make sure that the tests are passing in Github Actions.
  • This one is optional, but we should be using static analysis and linter tools to have a better codebase. A popular stack is: mypy, black, ruff, and isort. We can make use of these tools.
  • We should re-export our public APIs in __init__.py so that what is public could be detemined easily and the public APIs could be used easier.

package name

I believe the name of the library should be changed from upstash_py to upstash_redis. The py suffix does not add any value, and we have other products, so giving a more descriptive name with redis suffix would be better.

Include a timeout for `session.post` in `sync_execute`

In sync_execute, commands are executed by making requests to the Upstash REST API like this...

response = session.post(url, headers=headers, json=command).json()

...where session is a requests.Session instance.

As indicated by the requests documentation, this call should include a timeout to avoid blocking for long periods in the event of networking trouble:

Nearly all production code should use this parameter [timeout] in nearly all requests. Failure to do so can cause your program to hang indefinitely

For the Redis workloads I typically have, no response from Redis is better than a slow response from Redis. The client should at least allow users to configure a timeout for these requests, and in my opinion should also have a default timeout enabled without user intervention.

asyncio

  • Asyncio is not dominant yet. Providing an API only for it might hurt the adoption of the library. I think we should do what most of the other libraries do, and provide sync + async APIs on the same package, and the default implementation should have sync APIs: Basically, upstash_redis.Redis and upstash_redis.aio.Redis, which provides the sync and async versions of the same API.

naming

  • The implementation of the library currently deviates from the Redis command definitions on the parameter names. For example, we currently have the following API:

        async def set(
            self,
            key: str,
            value: Any,
            nx: bool = False,
            xx: bool = False,
            get: bool = False,
            seconds: int | None = None,
            milliseconds: int | None = None,
            unix_time_seconds: int | None = None,
            unix_time_milliseconds: int | None = None,
            keep_ttl: bool = False,
        ) -> str | None: ...

    However, the command definition on the Redis is as follows:

    SET key value [NX | XX] [GET] [EX seconds | PX milliseconds |
      EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL]
    

    IMO we should follow the command definitions. I gave an example for this specific command, but there might be other deviations.

reexport __init__.py

We should re-export our public APIs in init.py so that what is public could be detemined easily and the public APIs could be used easier.

tests

The current test suite is not enough. There are lots of commands which we don't have even a single test for. And, in my local environment, most of the tests are failing. We should fix this, and improve the test suite.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.