redis-data-structures


Nameredis-data-structures JSON
Version 0.1.24 PyPI version JSON
download
home_pageNone
SummaryRedis-backed data structures for building scalable and resilient applications
upload_time2024-12-31 10:35:53
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2024 Duy Huynh Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords bloom-filter data-structures deque graph hash-map lru-cache priority-queue queue redis ring-buffer set stack
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 🌟 Redis Data Structures

[![PyPI version](https://badge.fury.io/py/redis-data-structures.svg)](https://badge.fury.io/py/redis-data-structures)
![PyPI Downloads](https://static.pepy.tech/badge/redis-data-structures)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![codecov](https://codecov.io/gh/vndee/redis-data-structures/graph/badge.svg?token=O9DSUSEJCI)](https://codecov.io/gh/vndee/redis-data-structures)
[![code linting](https://github.com/vndee/redis-data-structures/actions/workflows/pylint.yaml/badge.svg)](https://github.com/vndee/redis-data-structures/actions/workflows/pylint.yaml)
[![tests](https://github.com/vndee/redis-data-structures/actions/workflows/pytest.yaml/badge.svg)](https://github.com/vndee/redis-data-structures/actions/workflows/pytest.yaml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A Python library providing high-level, Redis-backed data structures with a clean, Pythonic interface. Perfect for distributed systems, microservices, and any application requiring persistent, thread-safe data structures, especially in environments where multiple workers share the same data structure.

![Redis Data Structures (1)](assets/Redis%20Data%20Structures%20(1).png)


💡 **[Examples](examples/)**


### 📋 Table of Contents
- [✨ Features](#-features)
- [📦 Installation](#-installation)
- [🚀 Quick Start](#-quick-start)
- [📊 Data Structures](#-data-structures)
- [💻 Usage Examples](#-usage-examples)
- [🔗 Connection Management](#-connection-management)
- [🔍 Complex Types](#-complex-types)
- [🤝 Contributing](#-contributing)
- [📝 License](#-license)


### ✨ Features

- **Thread-safe** data structures backed by Redis
- Clean, **Pythonic interface**
- Connection pooling, **automatic retries**, and **circuit breaker** pattern for fault tolerance
- **Type preservation** for complex types
- **Automatic compression** of large data using zlib (configurable)
- **>90%** test coverage
- **Async support** (coming soon)

### 📦 Installation

```bash
pip install redis-data-structures
```

> **Note:** Ensure that Redis is running for the library to function properly.

### 🚀 Quick Start

```python
from redis_data_structures import Queue, Stack, Set, ConnectionManager

# Initialize connection
conn = ConnectionManager(host='localhost', port=6379, db=0)

# Create and use data structures
queue = Queue("tasks", connection_manager=conn)
queue.push({'id': 1, 'action': 'process'})

stack = Stack("commands", connection_manager=conn)
stack.push({'action': 'create'})

set_ds = Set("users", connection_manager=conn)
set_ds.add({'id': 'user1', 'name': 'Alice'})
```

You can also skip using `ConnectionManager` if the following environment variables are set:

- `REDIS_HOST`
- `REDIS_PORT`
- `REDIS_DB`
- `REDIS_USERNAME`
- `REDIS_PASSWORD`

```python
from redis_data_structures import Queue, Stack, Set

queue = Queue("test_queue")
stack = Stack("test_stack")
set_ds = Set("test_set")
```

Refer to **[initialization](docs/initialization.md)** for more information.


### 📊 Data Structures

| Structure       | Description                | Use Case                          |
|------------------|----------------------------|-----------------------------------|
| [Queue](docs/queue.md)            | FIFO queue                 | Job processing, message passing    |
| [Stack](docs/stack.md)            | LIFO stack                 | Undo systems, execution contexts   |
| [Set](docs/set.md)              | Unique collection          | Membership testing, deduplication  |
| [Dict](docs/dict.md)              | Python-like dictionary (key-value store)            | Caching, metadata storage          |
| [HashMap](docs/hash_map.md)          | Key-value store            | Caching, metadata storage          |
| [PriorityQueue](docs/priority_queue.md)    | Priority-based queue       | Task scheduling                    |
| [RingBuffer](docs/ring_buffer.md)       | Fixed-size circular buffer  | Logs, metrics                      |
| [Graph](docs/graph.md)            | Graph with adjacency list  | Relationships, networks            |
| [Trie](docs/trie.md)             | Prefix tree                | Autocomplete, spell checking       |
| [BloomFilter](docs/bloom_filter.md)      | Probabilistic set          | Membership testing                  |
| [Deque](docs/deque.md)            | Double-ended queue         | Sliding windows                    |


### 💻 Usage Examples

![Redis Data Structures (2)](assets/Redis%20Data%20Structures%20(2).png)

```python
from redis_data_structures import Queue

queue = Queue("tasks")

# Basic operations
queue.push({'id': 1, 'action': 'process'})
task = queue.pop()
size = queue.size()

stack = Stack("commands")
stack.push({'action': 'create'})
command = stack.pop()
size = stack.size()

set_ds = Set("users")
set_ds.add({'id': 'user1'})
exists = set_ds.contains({'id': 'user1'})
members = set_ds.members()

hash_map = HashMap("users")
hash_map.set('user:1', {'name': 'Alice', 'age': 30})
user = hash_map.get('user:1')
exists = hash_map.exists('user:1')

priority_queue = PriorityQueue("tasks")
priority_queue.push({'id': 1, 'priority': 1})
task = priority_queue.pop()
peek = priority_queue.peek()

...
```
For more examples, see **[examples](examples/)**.


### 🔗 Connection Management

```python
from redis_data_structures import ConnectionManager
from datetime import timedelta

conn = ConnectionManager(
    host='localhost',
    port=6379,
    db=0,
    max_connections=20,
    retry_max_attempts=5,
    circuit_breaker_threshold=10,
    circuit_breaker_timeout=timedelta(minutes=5),
    ssl=True
)

# Reuse for multiple queues
pq1 = PriorityQueue("tasks", connection_manager=conn)
pq2 = PriorityQueue("tasks", connection_manager=conn)

stack = Stack("commands", connection_manager=conn)
set_ds = Set("users", connection_manager=conn)
```

### 🔍 Complex Types

![Redis Data Structures (3)](assets/Redis%20Data%20Structures%20(3).png)

![Redis Data Structures (4)](assets/Redis%20Data%20Structures%20(4).png)


```python
from redis_data_structures import LRUCache, HashMap, SerializableType
from datetime import datetime, timezone
from pydantic import BaseModel

class User(SerializableType):
    """Example of a custom Redis data type using standard class."""

    def __init__(self, name: str, joined: datetime):
        """Initialize the User object."""
        self.name = name
        self.joined = joined

    def to_dict(self) -> dict:
        """Convert the User object to a dictionary."""
        return {
            "name": self.name,
            "joined": self.joined.isoformat(),  # Convert datetime to string
        }

    @classmethod
    def from_dict(cls, data: dict) -> "User":
        """Create a User object from a dictionary."""
        return cls(
            name=data["name"],
            joined=datetime.fromisoformat(data["joined"]),  # Convert string back to datetime
        )

    def __eq__(self, other) -> bool:
        """Override __eq__ for proper equality comparison."""
        return (
            isinstance(other, User) and 
            self.name == other.name and 
            self.joined == other.joined
        )

    def __str__(self) -> str:
        """Return a string representation of the User object."""
        return f"User(name='{self.name}', joined={self.joined.isoformat()})"


class Address(BaseModel):
    """Nested Pydantic model for demonstration."""

    street: str
    city: str
    country: str
    postal_code: Optional[str] = None


class UserModel(BaseModel):
    """Example of a Pydantic model - works automatically with Redis structures."""

    name: str
    email: str
    age: int = Field(gt=0, lt=150)
    joined: datetime
    address: Optional[Address] = None
    tags: Set[str] = set()

    def __str__(self) -> str:
        """Return a string representation of the UserModel instance."""
        return f"UserModel(name='{self.name}', email='{self.email}', age={self.age})"


# Initialize data structures
cache = LRUCache("test_cache", capacity=1000)  # Using default connection settings
hash_map = HashMap("type_demo_hash")  # Using default connection settings

# Example 1: Basic Python Types
data = {
    "string": "hello",
    "integer": 42,
    "float": 3.14,
    "boolean": True,
    "none": None,
}
for key, value in data.items():
    hash_map.set(key, value)
    result = hash_map.get(key)

# Example 2: Collections
collections = {
    "tuple": (1, "two", 3.0),
    "list": [1, 2, 3, "four"],
    "set": {1, 2, 3, 4},
    "dict": {"a": 1, "b": 2},
}
for key, value in collections.items():
    hash_map.set(key, value)
    result = hash_map.get(key)

# Example 3: DateTime Types
now = datetime.now(timezone.utc)
hash_map.set("datetime", now)
result = hash_map.get("datetime")

# Example 4: Custom Type
user = User("John Doe", datetime.now(timezone.utc))
hash_map.set("custom_user", user)
result = hash_map.get("custom_user")

# Example 5: Pydantic Models
user_model = UserModel(
    name="Jane Smith",
    email="jane@example.com",
    age=30,
    joined=datetime.now(timezone.utc),
    address=Address(
        street="123 Main St",
        city="New York",
        country="USA",
        postal_code="10001",
    ),
    tags={"developer", "python"},
)

# Store in different data structures
cache.put("pydantic_user", user_model)
hash_map.set("pydantic_user", user_model)

# Retrieve and verify
cache_result = cache.get("pydantic_user")
hash_result = hash_map.get("pydantic_user")

# Example 6: Nested Structures
nested_data = {
    "user": user,
    "model": user_model,
    "list": [1, user, user_model],
    "tuple": (user, user_model),
    "dict": {
        "user": user,
        "model": user_model,
        "date": now,
    },
}
hash_map.set("nested", nested_data)
result = hash_map.get("nested")

```

> **Important Note for Distributed Systems**: In scenarios where some processes only consume data (without storing any), you need to manually register types before deserializing since the type registering is only automatically done when storing data. This is common in worker processes, read-only replicas, or monitoring systems. Example:
> ```python
> from redis_data_structures import RedisDataStructure
> 
> # In consumer processes, register types before reading data
> redis_structure = RedisDataStructure(key="my_key")
> 
> # Register your custom types
> redis_structure.register_types(User)  # For SerializableType classes
> redis_structure.register_types(UserModel)  # For Pydantic models
>
> # Register multiple types at once
> redis_structure.register_types([User, UserModel])  # For multiple types
>
> # Now you can safely deserialize data
> user = hash_map.get("custom_user")  # Will correctly deserialize as User instance
> model = hash_map.get("pydantic_user")  # Will correctly deserialize as UserModel instance
> ```

See **[type preservation](docs/type_preservation.md)** for more information.

### 🤝 Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit changes (`git commit -m 'Add amazing feature'`)
4. Push to branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request


### 📝 License

This project is licensed under the MIT License - see the **[LICENSE](LICENSE)** file for details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "redis-data-structures",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "bloom-filter, data-structures, deque, graph, hash-map, lru-cache, priority-queue, queue, redis, ring-buffer, set, stack",
    "author": null,
    "author_email": "\"Duy V. Huynh\" <vndee.huynh@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/ee/e2/c1585fc985a3d4f85d8d67f16c1834d07bd9a29456236aa8cf2b24940f9a/redis_data_structures-0.1.24.tar.gz",
    "platform": null,
    "description": "# \ud83c\udf1f Redis Data Structures\n\n[![PyPI version](https://badge.fury.io/py/redis-data-structures.svg)](https://badge.fury.io/py/redis-data-structures)\n![PyPI Downloads](https://static.pepy.tech/badge/redis-data-structures)\n[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)\n[![codecov](https://codecov.io/gh/vndee/redis-data-structures/graph/badge.svg?token=O9DSUSEJCI)](https://codecov.io/gh/vndee/redis-data-structures)\n[![code linting](https://github.com/vndee/redis-data-structures/actions/workflows/pylint.yaml/badge.svg)](https://github.com/vndee/redis-data-structures/actions/workflows/pylint.yaml)\n[![tests](https://github.com/vndee/redis-data-structures/actions/workflows/pytest.yaml/badge.svg)](https://github.com/vndee/redis-data-structures/actions/workflows/pytest.yaml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA Python library providing high-level, Redis-backed data structures with a clean, Pythonic interface. Perfect for distributed systems, microservices, and any application requiring persistent, thread-safe data structures, especially in environments where multiple workers share the same data structure.\n\n![Redis Data Structures (1)](assets/Redis%20Data%20Structures%20(1).png)\n\n\n\ud83d\udca1 **[Examples](examples/)**\n\n\n### \ud83d\udccb Table of Contents\n- [\u2728 Features](#-features)\n- [\ud83d\udce6 Installation](#-installation)\n- [\ud83d\ude80 Quick Start](#-quick-start)\n- [\ud83d\udcca Data Structures](#-data-structures)\n- [\ud83d\udcbb Usage Examples](#-usage-examples)\n- [\ud83d\udd17 Connection Management](#-connection-management)\n- [\ud83d\udd0d Complex Types](#-complex-types)\n- [\ud83e\udd1d Contributing](#-contributing)\n- [\ud83d\udcdd License](#-license)\n\n\n### \u2728 Features\n\n- **Thread-safe** data structures backed by Redis\n- Clean, **Pythonic interface**\n- Connection pooling, **automatic retries**, and **circuit breaker** pattern for fault tolerance\n- **Type preservation** for complex types\n- **Automatic compression** of large data using zlib (configurable)\n- **>90%** test coverage\n- **Async support** (coming soon)\n\n### \ud83d\udce6 Installation\n\n```bash\npip install redis-data-structures\n```\n\n> **Note:** Ensure that Redis is running for the library to function properly.\n\n### \ud83d\ude80 Quick Start\n\n```python\nfrom redis_data_structures import Queue, Stack, Set, ConnectionManager\n\n# Initialize connection\nconn = ConnectionManager(host='localhost', port=6379, db=0)\n\n# Create and use data structures\nqueue = Queue(\"tasks\", connection_manager=conn)\nqueue.push({'id': 1, 'action': 'process'})\n\nstack = Stack(\"commands\", connection_manager=conn)\nstack.push({'action': 'create'})\n\nset_ds = Set(\"users\", connection_manager=conn)\nset_ds.add({'id': 'user1', 'name': 'Alice'})\n```\n\nYou can also skip using `ConnectionManager` if the following environment variables are set:\n\n- `REDIS_HOST`\n- `REDIS_PORT`\n- `REDIS_DB`\n- `REDIS_USERNAME`\n- `REDIS_PASSWORD`\n\n```python\nfrom redis_data_structures import Queue, Stack, Set\n\nqueue = Queue(\"test_queue\")\nstack = Stack(\"test_stack\")\nset_ds = Set(\"test_set\")\n```\n\nRefer to **[initialization](docs/initialization.md)** for more information.\n\n\n### \ud83d\udcca Data Structures\n\n| Structure       | Description                | Use Case                          |\n|------------------|----------------------------|-----------------------------------|\n| [Queue](docs/queue.md)            | FIFO queue                 | Job processing, message passing    |\n| [Stack](docs/stack.md)            | LIFO stack                 | Undo systems, execution contexts   |\n| [Set](docs/set.md)              | Unique collection          | Membership testing, deduplication  |\n| [Dict](docs/dict.md)              | Python-like dictionary (key-value store)            | Caching, metadata storage          |\n| [HashMap](docs/hash_map.md)          | Key-value store            | Caching, metadata storage          |\n| [PriorityQueue](docs/priority_queue.md)    | Priority-based queue       | Task scheduling                    |\n| [RingBuffer](docs/ring_buffer.md)       | Fixed-size circular buffer  | Logs, metrics                      |\n| [Graph](docs/graph.md)            | Graph with adjacency list  | Relationships, networks            |\n| [Trie](docs/trie.md)             | Prefix tree                | Autocomplete, spell checking       |\n| [BloomFilter](docs/bloom_filter.md)      | Probabilistic set          | Membership testing                  |\n| [Deque](docs/deque.md)            | Double-ended queue         | Sliding windows                    |\n\n\n### \ud83d\udcbb Usage Examples\n\n![Redis Data Structures (2)](assets/Redis%20Data%20Structures%20(2).png)\n\n```python\nfrom redis_data_structures import Queue\n\nqueue = Queue(\"tasks\")\n\n# Basic operations\nqueue.push({'id': 1, 'action': 'process'})\ntask = queue.pop()\nsize = queue.size()\n\nstack = Stack(\"commands\")\nstack.push({'action': 'create'})\ncommand = stack.pop()\nsize = stack.size()\n\nset_ds = Set(\"users\")\nset_ds.add({'id': 'user1'})\nexists = set_ds.contains({'id': 'user1'})\nmembers = set_ds.members()\n\nhash_map = HashMap(\"users\")\nhash_map.set('user:1', {'name': 'Alice', 'age': 30})\nuser = hash_map.get('user:1')\nexists = hash_map.exists('user:1')\n\npriority_queue = PriorityQueue(\"tasks\")\npriority_queue.push({'id': 1, 'priority': 1})\ntask = priority_queue.pop()\npeek = priority_queue.peek()\n\n...\n```\nFor more examples, see **[examples](examples/)**.\n\n\n### \ud83d\udd17 Connection Management\n\n```python\nfrom redis_data_structures import ConnectionManager\nfrom datetime import timedelta\n\nconn = ConnectionManager(\n    host='localhost',\n    port=6379,\n    db=0,\n    max_connections=20,\n    retry_max_attempts=5,\n    circuit_breaker_threshold=10,\n    circuit_breaker_timeout=timedelta(minutes=5),\n    ssl=True\n)\n\n# Reuse for multiple queues\npq1 = PriorityQueue(\"tasks\", connection_manager=conn)\npq2 = PriorityQueue(\"tasks\", connection_manager=conn)\n\nstack = Stack(\"commands\", connection_manager=conn)\nset_ds = Set(\"users\", connection_manager=conn)\n```\n\n### \ud83d\udd0d Complex Types\n\n![Redis Data Structures (3)](assets/Redis%20Data%20Structures%20(3).png)\n\n![Redis Data Structures (4)](assets/Redis%20Data%20Structures%20(4).png)\n\n\n```python\nfrom redis_data_structures import LRUCache, HashMap, SerializableType\nfrom datetime import datetime, timezone\nfrom pydantic import BaseModel\n\nclass User(SerializableType):\n    \"\"\"Example of a custom Redis data type using standard class.\"\"\"\n\n    def __init__(self, name: str, joined: datetime):\n        \"\"\"Initialize the User object.\"\"\"\n        self.name = name\n        self.joined = joined\n\n    def to_dict(self) -> dict:\n        \"\"\"Convert the User object to a dictionary.\"\"\"\n        return {\n            \"name\": self.name,\n            \"joined\": self.joined.isoformat(),  # Convert datetime to string\n        }\n\n    @classmethod\n    def from_dict(cls, data: dict) -> \"User\":\n        \"\"\"Create a User object from a dictionary.\"\"\"\n        return cls(\n            name=data[\"name\"],\n            joined=datetime.fromisoformat(data[\"joined\"]),  # Convert string back to datetime\n        )\n\n    def __eq__(self, other) -> bool:\n        \"\"\"Override __eq__ for proper equality comparison.\"\"\"\n        return (\n            isinstance(other, User) and \n            self.name == other.name and \n            self.joined == other.joined\n        )\n\n    def __str__(self) -> str:\n        \"\"\"Return a string representation of the User object.\"\"\"\n        return f\"User(name='{self.name}', joined={self.joined.isoformat()})\"\n\n\nclass Address(BaseModel):\n    \"\"\"Nested Pydantic model for demonstration.\"\"\"\n\n    street: str\n    city: str\n    country: str\n    postal_code: Optional[str] = None\n\n\nclass UserModel(BaseModel):\n    \"\"\"Example of a Pydantic model - works automatically with Redis structures.\"\"\"\n\n    name: str\n    email: str\n    age: int = Field(gt=0, lt=150)\n    joined: datetime\n    address: Optional[Address] = None\n    tags: Set[str] = set()\n\n    def __str__(self) -> str:\n        \"\"\"Return a string representation of the UserModel instance.\"\"\"\n        return f\"UserModel(name='{self.name}', email='{self.email}', age={self.age})\"\n\n\n# Initialize data structures\ncache = LRUCache(\"test_cache\", capacity=1000)  # Using default connection settings\nhash_map = HashMap(\"type_demo_hash\")  # Using default connection settings\n\n# Example 1: Basic Python Types\ndata = {\n    \"string\": \"hello\",\n    \"integer\": 42,\n    \"float\": 3.14,\n    \"boolean\": True,\n    \"none\": None,\n}\nfor key, value in data.items():\n    hash_map.set(key, value)\n    result = hash_map.get(key)\n\n# Example 2: Collections\ncollections = {\n    \"tuple\": (1, \"two\", 3.0),\n    \"list\": [1, 2, 3, \"four\"],\n    \"set\": {1, 2, 3, 4},\n    \"dict\": {\"a\": 1, \"b\": 2},\n}\nfor key, value in collections.items():\n    hash_map.set(key, value)\n    result = hash_map.get(key)\n\n# Example 3: DateTime Types\nnow = datetime.now(timezone.utc)\nhash_map.set(\"datetime\", now)\nresult = hash_map.get(\"datetime\")\n\n# Example 4: Custom Type\nuser = User(\"John Doe\", datetime.now(timezone.utc))\nhash_map.set(\"custom_user\", user)\nresult = hash_map.get(\"custom_user\")\n\n# Example 5: Pydantic Models\nuser_model = UserModel(\n    name=\"Jane Smith\",\n    email=\"jane@example.com\",\n    age=30,\n    joined=datetime.now(timezone.utc),\n    address=Address(\n        street=\"123 Main St\",\n        city=\"New York\",\n        country=\"USA\",\n        postal_code=\"10001\",\n    ),\n    tags={\"developer\", \"python\"},\n)\n\n# Store in different data structures\ncache.put(\"pydantic_user\", user_model)\nhash_map.set(\"pydantic_user\", user_model)\n\n# Retrieve and verify\ncache_result = cache.get(\"pydantic_user\")\nhash_result = hash_map.get(\"pydantic_user\")\n\n# Example 6: Nested Structures\nnested_data = {\n    \"user\": user,\n    \"model\": user_model,\n    \"list\": [1, user, user_model],\n    \"tuple\": (user, user_model),\n    \"dict\": {\n        \"user\": user,\n        \"model\": user_model,\n        \"date\": now,\n    },\n}\nhash_map.set(\"nested\", nested_data)\nresult = hash_map.get(\"nested\")\n\n```\n\n> **Important Note for Distributed Systems**: In scenarios where some processes only consume data (without storing any), you need to manually register types before deserializing since the type registering is only automatically done when storing data. This is common in worker processes, read-only replicas, or monitoring systems. Example:\n> ```python\n> from redis_data_structures import RedisDataStructure\n> \n> # In consumer processes, register types before reading data\n> redis_structure = RedisDataStructure(key=\"my_key\")\n> \n> # Register your custom types\n> redis_structure.register_types(User)  # For SerializableType classes\n> redis_structure.register_types(UserModel)  # For Pydantic models\n>\n> # Register multiple types at once\n> redis_structure.register_types([User, UserModel])  # For multiple types\n>\n> # Now you can safely deserialize data\n> user = hash_map.get(\"custom_user\")  # Will correctly deserialize as User instance\n> model = hash_map.get(\"pydantic_user\")  # Will correctly deserialize as UserModel instance\n> ```\n\nSee **[type preservation](docs/type_preservation.md)** for more information.\n\n### \ud83e\udd1d Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit changes (`git commit -m 'Add amazing feature'`)\n4. Push to branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n\n### \ud83d\udcdd License\n\nThis project is licensed under the MIT License - see the **[LICENSE](LICENSE)** file for details.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Duy Huynh  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Redis-backed data structures for building scalable and resilient applications",
    "version": "0.1.24",
    "project_urls": {
        "Documentation": "https://github.com/vndee/redis-data-structures#readme",
        "Homepage": "https://github.com/vndee/redis-data-structures",
        "Repository": "https://github.com/vndee/redis-data-structures"
    },
    "split_keywords": [
        "bloom-filter",
        " data-structures",
        " deque",
        " graph",
        " hash-map",
        " lru-cache",
        " priority-queue",
        " queue",
        " redis",
        " ring-buffer",
        " set",
        " stack"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "528023fbf978d5bdaa6104092ddb8c3f8d93f14dbded2210805298a86f4cc438",
                "md5": "5dcc2a6f4019d03224a009151fef184a",
                "sha256": "1afb097a85357bcf05c69b7b9f49965072152a0cf7aba8fbf9583bc9a2965aa2"
            },
            "downloads": -1,
            "filename": "redis_data_structures-0.1.24-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5dcc2a6f4019d03224a009151fef184a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 34537,
            "upload_time": "2024-12-31T10:35:41",
            "upload_time_iso_8601": "2024-12-31T10:35:41.713355Z",
            "url": "https://files.pythonhosted.org/packages/52/80/23fbf978d5bdaa6104092ddb8c3f8d93f14dbded2210805298a86f4cc438/redis_data_structures-0.1.24-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eee2c1585fc985a3d4f85d8d67f16c1834d07bd9a29456236aa8cf2b24940f9a",
                "md5": "55c44e1811517824de7e4079b415c9d4",
                "sha256": "418a39b123546f344c2ae55fbd21c9615fa952b7035fb912cb88d8c710fda625"
            },
            "downloads": -1,
            "filename": "redis_data_structures-0.1.24.tar.gz",
            "has_sig": false,
            "md5_digest": "55c44e1811517824de7e4079b415c9d4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5844998,
            "upload_time": "2024-12-31T10:35:53",
            "upload_time_iso_8601": "2024-12-31T10:35:53.686345Z",
            "url": "https://files.pythonhosted.org/packages/ee/e2/c1585fc985a3d4f85d8d67f16c1834d07bd9a29456236aa8cf2b24940f9a/redis_data_structures-0.1.24.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-31 10:35:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "vndee",
    "github_project": "redis-data-structures#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "redis-data-structures"
}
        
Elapsed time: 0.45380s