A easy way of setting up a redis in quart
Project description
Quart-Redis
An easy way of setting up a redis connection in quart.
View the docs here.
Requirements
- quart ~= 0.20
- redis >= 5.2.1, < 6
Example
# file: app.py
from quart import Quart
from quart_redis import RedisHandler, get_redis
app = Quart(__name__)
app.config["REDIS_URI"] = "redis://localhost"
# override default connection attempts, set < 0 to disable
# app.config["REDIS_CONN_ATTEMPTS"] = 3
redis_handler = RedisHandler(app)
@app.route("/")
async def index():
redis = get_redis()
val = await redis.get("my-key")
if val is None:
await redis.set("my-key", "it works!")
val = await redis.get("my-key")
return val
Testing
Due to quart_redis using before_serving and after_serving, using the Quart test_client requires the use of test_app. Pytest example shown below:
# file: test.py
import pytest
from app import app
@pytest.fixture(name="my_app", scope="function")
async def _my_app():
async with app.test_app() as test_app:
yield test_app
async def test_redis(my_app):
async with my_app.test_client() as client:
result = await client.get("/")
assert result == b"it works!"
Faking Redis
For development and testing, you may not have a running Redis instance. In this case, the fakeredis package may be installed and then used instead of actual redis by setting USE_FAKE_REDIS environment variable to true at runtime.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quart-redis-3.0.0.tar.gz.
File metadata
- Download URL: quart-redis-3.0.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec45d0535a6a6e0fd79b787173dd3cd51c7af5ab6d0bb285755e19bada56f8f9
|
|
| MD5 |
b824a854be43256c1d22d39c73b34b45
|
|
| BLAKE2b-256 |
959f065652204f581c446bdb368fd534b275efe2e79a4e118ee2d9c113dfe6b4
|
Provenance
The following attestation bundles were made for quart-redis-3.0.0.tar.gz:
Publisher:
python-publish.yml on enchant97/quart-redis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quart_redis-3.0.0.tar.gz -
Subject digest:
ec45d0535a6a6e0fd79b787173dd3cd51c7af5ab6d0bb285755e19bada56f8f9 - Sigstore transparency entry: 173501845
- Sigstore integration time:
-
Permalink:
enchant97/quart-redis@b9032fc845d9b83ff8d83cf3a7dc251b9437966c -
Branch / Tag:
refs/tags/v3.0.0 - Owner: https://github.com/enchant97
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b9032fc845d9b83ff8d83cf3a7dc251b9437966c -
Trigger Event:
release
-
Statement type:
File details
Details for the file quart_redis-3.0.0-py3-none-any.whl.
File metadata
- Download URL: quart_redis-3.0.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78a9f16b80e7ca17189a09b022734796bf21a41a4d0c09f05c51acdabc27cd23
|
|
| MD5 |
13982c939d35601aa9f2827f084f2f86
|
|
| BLAKE2b-256 |
beb80797dc45b917ed47618066ead68c08f7ad0a06375d99e54c89d7a0d43b3d
|
Provenance
The following attestation bundles were made for quart_redis-3.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on enchant97/quart-redis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quart_redis-3.0.0-py3-none-any.whl -
Subject digest:
78a9f16b80e7ca17189a09b022734796bf21a41a4d0c09f05c51acdabc27cd23 - Sigstore transparency entry: 173501846
- Sigstore integration time:
-
Permalink:
enchant97/quart-redis@b9032fc845d9b83ff8d83cf3a7dc251b9437966c -
Branch / Tag:
refs/tags/v3.0.0 - Owner: https://github.com/enchant97
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@b9032fc845d9b83ff8d83cf3a7dc251b9437966c -
Trigger Event:
release
-
Statement type: