Skip to main content

RemoteDict is a lightweight, in-memory key-value store server implemented in Python.

Project description

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:

    pip install redis
    

Usage Examples

Basic In-Memory Server (RemoteDict)

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)

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)

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)

python -m tests.run_tests

Run individual test suites

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.

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

pyremotedict-0.1.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

pyremotedict-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file pyremotedict-0.1.0.tar.gz.

File metadata

  • Download URL: pyremotedict-0.1.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for pyremotedict-0.1.0.tar.gz
Algorithm Hash digest
SHA256 014db5b356acea5bfb14d7caf84a3f235897d380ca5bd7822fbb50395b8e5c49
MD5 646e0cec48fd27132b29e8ea2f61e1a8
BLAKE2b-256 011c53bcdd05a5151ebced3e6541d7fc9fef93ea6972e65b2f31a5c465378f2e

See more details on using hashes here.

File details

Details for the file pyremotedict-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyremotedict-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for pyremotedict-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9e901e406f6b306cd85bf7bfa837240e8116ac7389bf63f6ee6a6d52e4b0f5f
MD5 6a13bd0913f6914d0bdced3b4520868a
BLAKE2b-256 950e582f89159bd2d8580b335e2f46ba52823e1049325a0a63d37c1cfa88fe4b

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