Skip to main content

(Redis Imaginary Nesting) brings poetic structure to Redis with elegant, nestable clusters—turning your keyspace into a meaningful, typed, and navigable hierarchy.

Project description

Redisimnest (Redis Imaginary Nesting)

MIT License

A sophisticated, prefix-based Redis key management system with customizable, nestable clusters, dynamic key types, and parameterized prefix resolution. Ideal for organizing application state and simplifying Redis interactions in complex systems.

Table of Contents

  • Installation
  • Usage
  • Features
  • Configuration
  • Contributing
  • License

Installation

You can install Redisimnest via pip:

pip install redisimnest

Alternatively, install from source:

git clone https://github.com/yourusername/redisimnest.git
cd redisimnest
pip install .

Usage

Here's a basic example of how to use Redisimnest in your project:

from asyncio import run
from redisimnest import BaseCluster, Key
from redisimnest.utils import RedisManager

# Define structured key clusters
class App:
    __prefix__ = 'app'
    __ttl__ = 80
    tokens = Key('tokens', default=[])
    pending_users = Key('pending_users')

class User:
    __prefix__ = 'user:{user_id}'
    __ttl__ = 120
    age = Key('age', 0)
    name = Key('name', "Unknown")

class RootCluster(BaseCluster):
    __prefix__ = 'root'
    app = App
    user = User
    project_name = Key('project_name')

# Initialize cluster
redis = RedisManager.get_client()
root = RootCluster(redis_client=redis)

# Use like a high-level Redis interface
async def main():
    await root.project_name.set("RedisimNest")
    await root.user(1).age.set(30)
    print(await root.user(1).age.get())           # ➜ 30
    await root.app.tokens.set(["token1", "token2"])
    await root.app.tokens.expire(60)
    await root.app.clear()                        # Clear all app-prefixed keys

run(main())

Features

  • Prefix-Based Cluster Management: Organize Redis keys with flexible, dynamic prefixes.
  • Support for Parameterized Keys:_ Create keys with placeholders that can be dynamically replaced._
  • TTL Management: Automatic and manual control over key TTLs.
  • Cluster Hierarchies: Nested clusters with inherited parameters.
  • Typed Key Classes: Use Python types to define and validate Redis key value structures.
  • Auto-Binding & Dynamic Access:_ Smart access to nested clusters and runtime bindings._
  • Command Dispatching: Type-aware command routing with serialization/deserialization support.

Configuration

Redisimnest allows you to customize the following settings:

  • REDIS_HOST: Redis server hostname (default: localhost).
  • REDIS_PORT: Redis server port (default: 6379).
  • REDIS_USERNAME / REDIS_PASS: Optional authentication credentials.
  • REDIS_DELETE_CHUNK_SIZE: Number of items deleted per operation (default: 50).

You can set these via environment variables or within your settings.py:

import os

REDIS_HOST = os.getenv("REDIS_HOST", "localhost")
REDIS_PORT = int(os.getenv("REDIS_PORT", "6379"))
REDIS_DELETE_CHUNK_SIZE = 50

To apply your custom settings file add USER_SETTINGS_FILE=./your_settings.py path to .env file

Contributing

We welcome contributions! To contribute:

1. Fork the repository. 2. Create a new branch (git checkout -b feature-branch). 3. Make your changes. 4. Write tests for your changes. 5. Submit a pull request.

Please ensure all tests pass before submitting your PR.

License

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

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

redisimnest-0.1.1.tar.gz (31.7 kB view details)

Uploaded Source

Built Distribution

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

redisimnest-0.1.1-py3-none-any.whl (37.5 kB view details)

Uploaded Python 3

File details

Details for the file redisimnest-0.1.1.tar.gz.

File metadata

  • Download URL: redisimnest-0.1.1.tar.gz
  • Upload date:
  • Size: 31.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for redisimnest-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0039f87a7d19017ada9404c563a6f975b93766ebeb428d70494407f83210e1ec
MD5 b0ff17d722fa54f81c20ffb693a52aec
BLAKE2b-256 9cebb9c28055b3d87f8299113b2c5123a05cd3a294dad08f269d83719840a190

See more details on using hashes here.

File details

Details for the file redisimnest-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: redisimnest-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 37.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for redisimnest-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 76fe0991a502da9a876652048bd0c0ac02733b960be8ed5d14ada9b546b3a76e
MD5 317036ae17f3e7f3cdf1aef5b2472765
BLAKE2b-256 6e766bb9ebe21e05ae15d3d4520efaf23420be0bf7d15ee73ca25272262253a8

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