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.7

Installation

Muffin-Redis should be installed using pip:

pip install muffin-redis

To install fakeredis (for testing purposes):

pip install muffin-redis[fake]

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

address

"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)

jsonify

False

Use json to store/read objects with get/set

fake

False

Use fakeredis. The option is convenient for testing

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

Uploaded Source

Built Distribution

muffin_redis-2.0.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file muffin-redis-2.0.0.tar.gz.

File metadata

  • Download URL: muffin-redis-2.0.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

File hashes

Hashes for muffin-redis-2.0.0.tar.gz
Algorithm Hash digest
SHA256 40f8907da6843bd5e13e62b54c0443024226cb8b1af0e9741caae822f2ee82c6
MD5 d3892e89beaffebaada5aab9cd916d09
BLAKE2b-256 47660a7c15acce2566aa189e373a0afe8b7cab391139910eb9ad78fc4a65e2d8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: muffin_redis-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

File hashes

Hashes for muffin_redis-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23bf5c89c110b174f234419c1384244bf101cf4cb5c81365d2e39038eb31f117
MD5 bad70a6c9835f5690d772cc997541190
BLAKE2b-256 5a0844f421704077b9ef070945b782bd6cecdf4c19089cb5765ca2effe1ceb77

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