Skip to main content

Redis support for Muffin framework.

Project description

Muffin-Redis

Muffin-Redis — Redis support for the Muffin framework.

Tests Status PyPI Version Python Versions


Features

  • Built on redis.asyncio client.
  • Optional support for fakeredis for testing without a real Redis server.
  • JSON serialization support
  • Automatic connection pool management (blocking or non-blocking).
  • Simple get() / set() with optional jsonify flag.
  • Lifecycle support: startup and shutdown integrate with Muffin app lifecycle.

Requirements

  • Python >= 3.11

Installation

Install using pip:

pip install muffin-redis

Optionally with fakeredis:

pip install muffin-redis[fakeredis]

Usage

Setup the plugin and connect it into your app:

from muffin import Application
from muffin_redis import Plugin as Redis

app = Application('example')

# Initialize the plugin
redis = Redis(address='redis://localhost')
redis.setup(app)

You can now use Redis in your routes:

@app.route('/some_url', methods=['POST'])
async def some_method(request):
    value = await redis.get('key')
    if value is None:
        value = ...  # Do some work
        await redis.set('key', value, expire=60)
    return value

Under the hood, Muffin-Redis uses aioredis for asynchronous Redis support.

Configuration Options

Name Default Description
url "redis://localhost" Redis connection URL
db None Redis DB index
password None Redis password
encoding "utf-8" Encoding used by the client
poolsize 10 Max pool size (set 0 to disable pooling)
decode_responses True Whether to decode binary responses
jsonify False Automatically encode/decode JSON with get/set
blocking True Use a blocking connection pool
timeout 20 Timeout in seconds for getting a connection
fake False Use fakeredis instead of a real Redis server

Bug Tracker

Please report bugs or feature requests at: https://github.com/klen/muffin-redis/issues

Contributing

Development happens at: https://github.com/klen/muffin-redis

License

Licensed under the MIT license.

Credits

  • Created by klen (Kirill Klenov)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

muffin_redis-4.0.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

muffin_redis-4.0.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file muffin_redis-4.0.0.tar.gz.

File metadata

  • Download URL: muffin_redis-4.0.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for muffin_redis-4.0.0.tar.gz
Algorithm Hash digest
SHA256 a30ccf8cc0e58b43341ef0a577d0abbe9b8a3854189bf987ca941706b1ac4f2f
MD5 7f0d2283b312c185d789622766fe40da
BLAKE2b-256 239e8abbfb40fd3ddffb9be1a244c6f9de80c0c53de2754c1f1a06b1857e2818

See more details on using hashes here.

File details

Details for the file muffin_redis-4.0.0-py3-none-any.whl.

File metadata

  • Download URL: muffin_redis-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for muffin_redis-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ab498ad9e11482b7b0f375b9d6a892511ab04165c723178fca7d142e5390795
MD5 e1da2996b8e506090a223cf72fa8d5eb
BLAKE2b-256 b2beee5a2e2e54153c511187ffccde6ebd96ef500eba0f7a30b6760cede790e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page