Skip to main content

Redis Tools for FastPluggy

Redis Tools redis_tools Pipeline Status Coverage

A powerful Redis browser and management plugin for FastPluggy applications. This plugin provides a user-friendly interface to browse, search, and manage Redis databases and keys.

Features

  • Redis Browser UI: Intuitive web interface to browse and manage Redis data
  • Multi-Database Support: Switch between Redis databases easily
  • Key Management: View, search, and delete Redis keys
  • Data Type Support: Full support for all Redis data types (string, list, hash, set, zset)
  • Safe value display: UTF-8 text and JSON are shown as text; a Python pickle is named (<pickled Python object, N bytes, not decoded>) and never loaded, since loading a pickle runs the code it carries; other binary values show their size and first bytes in hex
  • Administrators only: every page and route needs the fp_admin role; the routes that change Redis also refuse a request sent from another site
  • TTL Management: View time-to-live for keys
  • Database Flushing: Clear entire databases with confirmation
  • Flush Task: A task_flush_db task for the tasks_worker plugin, to flush a database from a worker, on demand or on a schedule

Installation

  1. Install the official plugin package:
pip install fastpluggy-plugins

or

pip install fastpluggy-plugin-redis
  1. Add the plugin to your FastPluggy application:

There are several ways to add the plugin to your FastPluggy application:

Method 1: Using the Admin Interface

  1. Navigate to /admin/plugins in your FastPluggy application
  2. Click on "Install New Plugin"
  3. Enter "redis_tools" as the plugin name
  4. Click "Install"

Method 2: Using the Configuration File

Add the plugin to your FastPluggy configuration file:

# config.py
FASTPLUGGY_PLUGINS = [
    # other plugins...
    "redis_tools",
]

Method 3: Programmatically

Add the plugin programmatically in your application code:

from fastapi import FastAPI
from fastpluggy import FastPluggy

app = FastAPI()
pluggy = FastPluggy(app)

# Add the Redis Tools plugin
pluggy.add_plugin("redis_tools")

For more detailed installation and configuration instructions, see the Installation Guide.

Configuration

Configure Redis Tools through environment variables or directly in your FastPluggy configuration:

Setting Description Default
REDIS_DSN Redis connection string (overrides other connection settings if provided) None
redis_host Redis server hostname localhost
redis_port Redis server port 6379
redis_db Default Redis database index 0
use_ssl Whether to use SSL for Redis connection False
redis_password Redis server password None
redis_decode_responses Whether to decode Redis responses False
keys_limit Maximum number of keys to display 100

Usage

Web Interface

Once installed, access the Redis browser at /redis_tools/ in your FastPluggy application. The interface allows you to:

  1. Select and switch between Redis databases
  2. Search for keys using patterns (e.g., user:*)
  3. View key details including type, TTL, and size
  4. Examine and format key values based on their data type
  5. Delete individual keys
  6. Flush entire databases

Programmatic Usage

You can also use the Redis Tools connector in your code:

from redis_tools.redis_connector import RedisConnection

# Create a connection
redis_conn = RedisConnection()

# Test connection
if redis_conn.test_connection():
    # Get all keys matching a pattern
    keys = redis_conn.get_keys("user:*")

    # Get details for a specific key
    key_details = redis_conn.get_key_details("user:1001")

    # Switch to another database
    redis_conn.select_db(2)

    # Delete a key
    redis_conn.delete_key("temporary_key")

Flushing a database from a worker

With the tasks_worker plugin installed, Redis Tools gives it one task, task_flush_db(db): it deletes every key of one database (FLUSHDB). tasks_worker finds it by itself when it loads; there is nothing to register. Without tasks_worker the task does not exist, and the plugin page of Redis Tools lists tasks_worker as a companion that is not loaded.

Run it once, from code:

from fastpluggy_plugin.tasks_worker import TaskWorker
from fastpluggy_plugin.redis_tools.tasks.purge import task_flush_db

TaskWorker.submit(task_flush_db, kwargs={"db": 3})

or from the "Run task" page of tasks_worker (task task_flush_db, argument db).

Run it on a schedule (created disabled; enable it on the Schedules page of tasks_worker, and keep one beat process running):

TaskWorker.add_scheduled_task(
    function=task_flush_db,
    task_name="flush_cache_db",
    cron="0 4 * * *",        # every day at 04:00 UTC
    kwargs={"db": 3},
)

The task deletes everything in the database it is given, with no confirmation. Redis removes expired keys by itself: no task is needed for that.

Development

Requirements

  • Python 3.10+
  • FastPluggy
  • Redis

Testing

Run tests with pytest:

cd redis_tools
pip install -e ".[tests]"
pytest

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for fastpluggy-redis 0.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastpluggy-redis 0.1.10
File Size Uploaded Provenance Actions
fastpluggy_redis-0.1.10.tar.gz 27.4 kB Without provenance Details for fastpluggy_redis-0.1.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fastpluggy-redis 0.1.10
File Interpreter ABI Platform Actions
fastpluggy_redis-0.1.10-py3-none-any.whl Python 3 none any Details for fastpluggy_redis-0.1.10-py3-none-any.whl

Total release size: 53.4 kB

Release files / fastpluggy_redis-0.1.10.tar.gz

Download URL fastpluggy_redis-0.1.10.tar.gz
Size 27.4 kB
Tags Source
SHA-256 checksum
How to use checksums
28904520e35a4f4c1fb9e9bb44e455feb1d2c74b4b2c0ace93f42f3b61bc3d55
BLAKE2b-256 checksum
How to use checksums
1865148600f5fbf3e027f9c0a1a19b1fc86287e6c97e0db436a0122b84678e45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release files / fastpluggy_redis-0.1.10-py3-none-any.whl

Download URL fastpluggy_redis-0.1.10-py3-none-any.whl
Size 26.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3fbd93ea31c6fa6e8ab587a43e1f56eddfe961c99987761dea649213f914c93d
BLAKE2b-256 checksum
How to use checksums
b9b9348b25e0ed0a01a8ca9f1e997b9a69437efb2ddd322e59013b899ce92fd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Security for fastpluggy-redis 0.1.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.10 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page