Metadata-Version: 2.4
Name: pyRemoteDict
Version: 0.1.0
Summary: RemoteDict is a lightweight, in-memory key-value store server implemented in Python.
Home-page: https://github.com/technojo2000/RemoteDict
Author: TechnoJo
License: MIT License
        
        Copyright (c) 2025 TechnoJo
        
        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.
        
Project-URL: Homepage, https://github.com/technojo2000/RemoteDict
Project-URL: Repository, https://github.com/technojo2000/RemoteDict
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

> **Disclaimer:** The majority of the code in this project was generated by AI (GitHub Copilot and similar tools). Please review and test thoroughly before using in production.

# RemoteDict: A Minimal Redis-like In-Memory Dictionary Server

RemoteDict is a lightweight, in-memory key-value store server implemented in Python. It mimics a subset of the Redis protocol and can be accessed using any Redis client library (such as `redis-py`).

## Features
- RESP protocol support for basic commands: `SET`, `GET`, `DEL`, `EXISTS`, `KEYS`
- In-memory storage (no persistence) via `RemoteDict`
- Expiring keys (with TTL) via `ExpiringRemoteDict`
- Persistent storage (disk-backed) via `PersistentRemoteDict`
- Asyncio-based server with optional threaded start/stop
- Compatible with Redis clients (e.g., `redis-py`)

## Installation
1. Clone this repository or copy the relevant files from `src/remotedict/` into your project.
2. Install the required client library:
   
   ```shell
   pip install redis
   ```

## Usage Examples

### Basic In-Memory Server (`RemoteDict`)
```python
import time
import redis
from remotedict import RemoteDict

# Start the server in a background thread
server = RemoteDict(address="127.0.0.1", port=8085)
server.start_thread()
time.sleep(0.5)  # Give the server a moment to start

# Connect as a client using redis-py
r = redis.Redis(host="127.0.0.1", port=8085, decode_responses=True)

# SET key value
r.set("foo", "bar")

# GET key
print(r.get("foo"))  # Output: bar

server.stop_thread()
```

### Expiring Keys (`ExpiringRemoteDict`)
```python
from remotedict import ExpiringRemoteDict

# All keys will expire after 5 seconds (default expiry for all keys)
server = ExpiringRemoteDict(address="127.0.0.1", port=8086, expiry_seconds=5)
server.start_thread()
# ...
# All keys set will automatically expire after 5 seconds
# ...
server.stop_thread()
```

### Persistent Storage (`PersistentRemoteDict`)
```python
from remotedict import PersistentRemoteDict

server = PersistentRemoteDict(address="127.0.0.1", port=8087, db_path="./mydb.json")
server.start_thread()
# ...
# Data will be saved to disk and reloaded on restart
# ...
server.stop_thread()
```

## Testing
You can run the test suites for all variants using unittest or by running the provided test runner script.

### Run all tests (recommended)
```shell
python -m tests.run_tests
```

### Run individual test suites
```shell
python -m unittest tests/test_remotedict_server.py
python -m unittest tests/test_expiring_remotedict_server.py
python -m unittest tests/test_persistent_remotedict_server.py
```

All tests should pass if the server and its variants are working correctly.

## Supported Commands
- `SET key value` — Set the value for a key
- `GET key` — Get the value for a key
- `DEL key [key ...]` — Delete one or more keys
- `EXISTS key [key ...]` — Check if one or more keys exist
- `KEYS pattern` — List keys matching a pattern (supports Unix shell-style wildcards)
- `FLUSHDB` — Remove all keys from the current database
- `FLUSHALL` — Remove all keys from all databases (if supported)

## Notes
- Expiry in `ExpiringRemoteDict` is global: all keys expire after the configured `expiry_seconds` (default: 3600 seconds). There is no per-key expiry or TTL/EXPIRE command support.
- This server is for educational/testing purposes and is not suitable for production use.
- Data is stored in memory and will be lost when the server stops, except when using `PersistentRemoteDict`.
- Expiry and persistence features are only available in their respective variants.
