prolly-store-redis
Redis-backed remote store adapter for prolly-map.
This crate implements RemoteStoreBackend for Redis and is intended for async
prolly-map use through RemoteProllyStore and AsyncProlly.
Installation
[]
= "0.4"
= "0.3.0"
= { = "1", = ["macros", "rt-multi-thread"] }
When to use it
Use this adapter when you want a low-latency remote Prolly tree store and your Redis deployment is configured with the durability level your application needs. It is a good fit for edge caches, collaborative sessions, test environments, and small to medium shared state where Redis persistence, replication, or managed service guarantees are acceptable.
Do not treat a default in-memory Redis instance as durable storage. For production, configure AOF/RDB persistence, replication, backups, eviction policy, memory limits, and access control explicitly.
Data model
The adapter stores three logical families under a configurable binary key prefix:
node:content-addressed Prolly tree nodes keyed by CID bytes.root:named root manifests for durable branch/checkpoint names.hint:optional traversal hints, such as the append rightmost-path hint.
Redis operations used by the adapter include GET, SET, DEL, MGET,
SCAN, and pipelined writes.
Setup
Run Redis locally:
Or use the Prolly service compose file from the Prolly repo root:
Set the connection URL:
Basic usage
use ;
use RedisBackend;
# async
Diff and merge
Redis stores all nodes needed by multiple immutable tree versions, so you can branch, diff, and merge without copying the full map:
# use ;
# use RedisBackend;
# async
Namespacing and cleanup
Use with_key_prefix whenever a Redis database is shared by tests, services, or
tenants. clear_namespace deletes every key under the current prefix and should
be used only for isolated test namespaces:
# async
Transactions and durability
The backend advertises strict transaction support. It uses a Lua script to validate named-root preconditions and apply the associated node and root writes atomically. A stale precondition returns a conflict without applying the staged writes.
These atomicity guarantees do not replace Redis persistence. Configure AOF/RDB, replication, eviction, backups, and memory limits according to the durability required by the application. Deleting a named root does not immediately delete unreachable nodes.
Running the example
From the standalone repository root:
The example writes a unique Redis namespace, publishes a named root, reloads it, runs diff/merge, and resolves a merge conflict.
Testing
The integration test runs when PROLLY_STORE_REDIS_URL is set and returns
without connecting otherwise:
The test selects a unique key prefix and removes only that namespace.
See the prolly-map API documentation for the
async map, transaction, diff, and merge APIs used with this backend.