Convert Figma logo to code with AI

aio-libs-abandoned logoaioredis-py

asyncio (PEP 3156) Redis support

2,297
336
2,297
95

Top Related Projects

12,531

Redis Python client

1,063

Redis for humans. 🌎🌍🌏

asyncio (PEP 3156) Redis support

1,148

Lightweight Python utilities for working with Redis

Quick Overview

The aioredis-py project is an asynchronous Python client library for the Redis in-memory data structure store. It provides a high-level API for interacting with Redis servers, allowing developers to leverage the power of Redis in their asynchronous Python applications.

Pros

  • Asynchronous Capabilities: aioredis-py is built on top of the asyncio library, enabling efficient and scalable asynchronous operations with Redis.
  • Pythonic Interface: The library offers a Pythonic interface, making it easy for Python developers to work with Redis without having to deal with low-level details.
  • Comprehensive Feature Set: The library supports a wide range of Redis commands and features, including transactions, pub/sub, and connection pooling.
  • Actively Maintained: Although the project is currently marked as "abandoned", the library is still actively maintained and receives updates from the community.

Cons

  • Abandoned Project Status: The project is currently marked as "abandoned" on GitHub, which may raise concerns about its long-term viability and support.
  • Limited Documentation: The project's documentation could be more comprehensive, making it challenging for new users to get started with the library.
  • Potential Compatibility Issues: As an abandoned project, there may be compatibility issues with newer versions of Python or Redis, which could require additional effort to resolve.
  • Limited Community Support: With the project being abandoned, the level of community support and contributions may be lower compared to more actively maintained libraries.

Code Examples

Here are a few code examples demonstrating the usage of aioredis-py:

Connecting to a Redis Server:

import asyncio
import aioredis

async def main():
    redis = await aioredis.create_redis_pool('redis://localhost')
    await redis.set('key', 'value')
    value = await redis.get('key')
    print(value)
    redis.close()
    await redis.wait_closed()

asyncio.run(main())

Performing a Redis Transaction:

import asyncio
import aioredis

async def main():
    redis = await aioredis.create_redis_pool('redis://localhost')
    async with redis.pipeline() as pipe:
        pipe.incr('counter')
        pipe.incr('counter')
        result = await pipe.execute()
    print(result)  # Output: [1, 2]
    redis.close()
    await redis.wait_closed()

asyncio.run(main())

Implementing a Redis Pub/Sub Pattern:

import asyncio
import aioredis

async def subscriber():
    redis = await aioredis.create_redis_pool('redis://localhost')
    channel, = await redis.subscribe('my-channel')
    async for message in channel.iter():
        print(f'Received message: {message}')
    redis.close()
    await redis.wait_closed()

async def publisher():
    redis = await aioredis.create_redis_pool('redis://localhost')
    await redis.publish('my-channel', 'Hello, Redis!')
    redis.close()
    await redis.wait_closed()

async def main():
    await asyncio.gather(
        subscriber(),
        publisher(),
    )

asyncio.run(main())

Getting Started

To get started with aioredis-py, follow these steps:

  1. Install the library using pip:

    pip install aioredis
    
  2. Import the necessary modules and create a Redis connection pool:

    import asyncio
    import aioredis
    
    async def main():
        redis = await aioredis.create_redis_pool('redis://localhost')
        # Use the Redis connection pool to interact with Redis
        # ...
        redis.close()
        await redis.wait_closed()
    
    asyncio.run(main())
    
  3. Interact with Redis using the provided API, such as setting and getting keys, performing transactions, and implementing pub/sub patterns.

  4. Refer to the project's documentation for more detailed information on the available features and usage examples.

Competitor Comparisons

12,531

Redis Python client

Pros of redis-py

  • Actively maintained and widely used in production environments
  • Comprehensive support for Redis features and commands
  • Extensive documentation and community support

Cons of redis-py

  • Synchronous by default, requiring additional setup for asynchronous operations
  • Potentially slower performance in high-concurrency scenarios compared to aioredis-py

Code Comparison

redis-py (synchronous):

import redis

r = redis.Redis(host='localhost', port=6379, db=0)
r.set('foo', 'bar')
value = r.get('foo')

aioredis-py (asynchronous):

import aioredis

async def main():
    redis = await aioredis.create_redis_pool('redis://localhost')
    await redis.set('foo', 'bar')
    value = await redis.get('foo')
    redis.close()
    await redis.wait_closed()

Key Differences

  • redis-py is synchronous by default, while aioredis-py is built for asynchronous operations
  • aioredis-py is specifically designed for use with asyncio, making it more suitable for asynchronous applications
  • redis-py has a larger user base and more extensive documentation
  • aioredis-py may offer better performance in high-concurrency scenarios due to its asynchronous nature

Note that aioredis-py is now abandoned, and users are encouraged to migrate to other async Redis libraries or use redis-py with its async capabilities.

1,063

Redis for humans. 🌎🌍🌏

Pros of Pottery

  • Comprehensive Redis Client: Pottery provides a comprehensive Redis client with support for a wide range of Redis commands, making it a powerful tool for working with Redis in your Python applications.
  • Asynchronous Support: Like aioredis-py, Pottery is built on top of the asyncio library, allowing for efficient and scalable asynchronous operations.
  • Intuitive API: Pottery's API is designed to be intuitive and easy to use, with a focus on developer productivity and ease of integration.

Cons of Pottery

  • Smaller Community: While Pottery is a well-designed library, it has a smaller community compared to aioredis-py, which may mean fewer resources and support available.
  • Fewer Features: Pottery may not have the same level of feature parity as aioredis-py, which has been actively developed for a longer period of time.
  • Potential Compatibility Issues: As a newer library, Pottery may have a higher risk of compatibility issues with certain Redis versions or other dependencies.

Code Comparison

Here's a brief code comparison between aioredis-py and Pottery for a simple Redis operation:

aioredis-py:

import asyncio
import aioredis

async def main():
    redis = await aioredis.create_redis_pool('redis://localhost')
    await redis.set('key', 'value')
    value = await redis.get('key')
    print(value)
    redis.close()
    await redis.wait_closed()

asyncio.run(main())

Pottery:

import asyncio
from pottery import Redis

async def main():
    redis = Redis(host='localhost')
    await redis.set('key', 'value')
    value = await redis.get('key')
    print(value)

asyncio.run(main())

As you can see, the Pottery code is slightly more concise and easier to read, thanks to its intuitive API. However, aioredis-py may offer more advanced features and a larger community for support.

asyncio (PEP 3156) Redis support

Pros of aioredis-py

  • More active development and maintenance
  • Better documentation and examples
  • Wider community support and contributions

Cons of aioredis-py

  • Potentially less stable due to more frequent updates
  • May have more dependencies or complexity

Code Comparison

aioredis-py:

import aioredis

async def main():
    redis = await aioredis.create_redis_pool('redis://localhost')
    await redis.set('key', 'value')
    value = await redis.get('key')
    print(value)
    redis.close()
    await redis.wait_closed()

aioredis:

import aioredis

async def main():
    redis = await aioredis.create_connection('redis://localhost')
    await redis.execute('SET', 'key', 'value')
    value = await redis.execute('GET', 'key')
    print(value)
    redis.close()
    await redis.wait_closed()

The main difference in the code examples is the API style. aioredis-py uses a more Pythonic approach with methods like set() and get(), while aioredis uses the execute() method with Redis commands as arguments.

Both libraries provide asynchronous Redis functionality for Python, but aioredis-py seems to have more active development and community support. However, this may come at the cost of potential instability due to frequent updates. The choice between the two depends on specific project requirements and preferences for API style.

1,148

Lightweight Python utilities for working with Redis

Pros of Walrus

  • Walrus provides a simple and intuitive API for working with Redis, making it easier to use than the lower-level aioredis-py library.
  • Walrus includes a number of built-in data structures and utilities, such as sets, hashes, and counters, which can save time and effort when building Redis-backed applications.
  • Walrus is actively maintained and has a larger community of users and contributors compared to the abandoned aioredis-py project.

Cons of Walrus

  • Walrus is a higher-level library, which means it may not provide the same level of control and flexibility as the lower-level aioredis-py library.
  • Walrus is not as widely used as some other Redis clients, which may make it harder to find community support and resources.
  • Walrus may have a steeper learning curve for developers who are more familiar with the lower-level Redis API.

Code Comparison

aioredis-py:

import asyncio
import aioredis

async def main():
    redis = await aioredis.create_redis_pool('redis://localhost')
    await redis.set('key', 'value')
    value = await redis.get('key')
    print(value)
    redis.close()
    await redis.wait_closed()

asyncio.run(main())

Walrus:

from walrus import Database

db = Database()

@db.task
async def main():
    await db.set('key', 'value')
    value = await db.get('key')
    print(value)

main()

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

aioredis


📢🚨 Aioredis is now in redis-py 4.2.0rc1+ 🚨🚨

Aioredis is now in redis-py 4.2.0rc1+

To install, just do pip install redis>=4.2.0rc1. The code is almost the exact same. You will just need to import like so:

from redis import asyncio as aioredis

This way you don't have to change all your code, just the imports.

https://github.com/redis/redis-py/releases/tag/v4.2.0rc1

Now that aioredis is under Redis officially, I hope there will never be an unmaintained, asyncio Redis lib in the Python ecosystem again. I will be helping out maintenance at Redis-py for the foreseeable future just to get some of the asyncio stuff out of the way. There are also some bugs that didn't make it into the PR that I'll be slowly migrating over throughout the next few weeks -- so long as my exams don't kill me beforehand :)

Thank you all so much for your commitment to this repository! Thank you so much to @abrookins @seandstewart @bmerry for all the commits and maintenance. And thank you to everyone here who has been adopting the new code base and squashing bugs. It's been an honor!

Cheers, Andrew


asyncio (3156) Redis client library.

The library is intended to provide simple and clear interface to Redis based on asyncio.

Features

FeatureSupported
hiredis parser:white_check_mark:
Pure-python parser:white_check_mark:
Low-level & High-level APIs:white_check_mark:
Pipelining support:white_check_mark:
Multi/Exec support:white_check_mark:
Connections Pool:white_check_mark:
Pub/Sub support:white_check_mark:
Sentinel support:white_check_mark:
ACL support:white_check_mark:
Streams support:white_check_mark:
Redis Cluster support:no_entry_sign:
Tested Python versions3.6, 3.7, 3.8, 3.9, 3.10
Tested for Redis servers5.0, 6.0
Support for dev Redis serverthrough low-level API

Installation

The easiest way to install aioredis is by using the package on PyPi:

pip install aioredis

Recommended with hiredis for performance and stability reasons:

pip install hiredis

Requirements

  • Python 3.6+
  • hiredis (Optional but recommended)
  • async-timeout
  • typing-extensions

Benchmarks

Benchmarks can be found here: https://github.com/popravich/python-redis-benchmark

Contribute

Feel free to file an issue or make pull request if you find any bugs or have some suggestions for library improvement.

License

The aioredis is offered under a MIT License.