Skip to main content

Redis support for Muffin framework.

Project description

Muffin-Redis – Redis support for Muffin framework.

Tests Status PYPI Version Python Versions

Requirements

  • python >= 3.8

Installation

Muffin-Redis should be installed using pip:

pip install muffin-redis

Optionally you may install the plugin with redislite:

$ pip install muffin-redis[redislite]

Usage

Setup the plugin and connect it into your app:

from muffin import Application
from muffin_redis import Plugin as Redis

# Create Muffin Application
app = Application('example')

# Initialize the plugin
# As alternative: redis = Redis(app, **options)
redis = Redis(address='redis://localhost')
redis.setup(app)

That’s it now you are able to use the plugin inside your views:

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

    return value

For Asyncio the muffin-redis uses aioredis library. So check the library’s docs for futher reference.

Configuration options

Name

Default value

Description

url

"redis://localhost"

Redis connection URL

db

None

Number of the Redis DB

password

None

Connection password

encoding

"utf-8"

Connection encoding

poolsize

10

Connections pool size (set 0 to disable pooling)

decode_responses

True

Decode binary responses

jsonify

False

Use json to store/read objects with get/set

blocking

True

Wait for an available connection

timeout

20

Timeout to get a connection

redislite

False

Use redislite instead of redis

pytest

True

Pytest integration: flush redis before each test

Bug tracker

If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/muffin-redis/issues

Contributing

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

Contributors

  • klen (Kirill Klenov)

License

Licensed under a MIT license.

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-3.6.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

muffin_redis-3.6.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: muffin_redis-3.6.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.15.0-1041-azure

File hashes

Hashes for muffin_redis-3.6.0.tar.gz
Algorithm Hash digest
SHA256 8a1c8bc6347601bc5fbb40f6ce6c84f4cb4250e0a4b5b498b8879cfcbc64b590
MD5 653800bfee7a0959f78d0f15979bf8c8
BLAKE2b-256 1aaa7cd3b4db780a0e32f030379314d384872ef7214515a4f781ca5c560b96fa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: muffin_redis-3.6.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.15.0-1041-azure

File hashes

Hashes for muffin_redis-3.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b866b667d416458d6238d3c18c50417d02b9a2471d93d1b2322f6a148e1a782d
MD5 a995c6840070216ea5a72ab7c44bb8a8
BLAKE2b-256 d9a11c208d7625c5f2ebb96e717590facf1fa0dadb34627f387ea4a7c14d8110

See more details on using hashes here.

Supported by

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