Spedo
SPEDO ENGINE
v0.69.0 PREVIEW
← Documentation

Multi-RAM Isolated Partitions & Memory Spaces

Since version v0.55.0

Spedo introduces Multi-RAM Isolated Partitions & Memory Spaces, enabling dedicated in-memory sub-regions with custom eviction policies, isolated memory quotas, and cross-space atomic merge capabilities.


1. Overview & Architecture

Multi-tenant architectures, AI vector search pipelines, and microservice sessions frequently require conflicting memory management policies:

Multi-RAM allows creating isolated spaces in a single Spedo instance without deploying multiple separate Redis processes.

+-------------------------------------------------------------------------+
|                        SPEDO SERVER INSTANCE                            |
|                                                                         |
|  +---------------------+  +---------------------+  +-----------------+  |
|  |  [default] Space    |  |  [ai_vectors] Space |  | [sessions]      |  |
|  |  Policy: LRU        |  |  Policy: VectorAI   |  | Policy: Ephem   |  |
|  |  Max: 128 MB        |  |  Max: 512 MB        |  | Max: 64 MB      |  |
|  +---------------------+  +---------------------+  +-----------------+  |
|             \                        |                       /          |
|              ================================================           |
|                                     |                                   |
|                        Cross-Space Atomic Merge                         |
+-------------------------------------------------------------------------+

2. Partition Policies

PolicyDescriptionTypical Use Case
ephemeralStrict volatile expiry; oldest TTLs evicted first on pressureWeb sessions, ephemeral caches, rate limits
transactionalStrict zero eviction; mutations reject with OOM before dropping stateFinancial records, state machines, tokens
vector_aiHigh-dimensional embedding store with HNSW vector index supportLLM semantic caches, RAG vector embeddings
crdtConflict-free replicated data types with version trackingDistributed state synchronization, edge replicas

3. RESP Protocol Commands

RAM.CREATE

Creates a new named RAM partition:

RAM.CREATE <space_name> <policy> [MAXMEMORY <bytes>]

RAM.LIST

Lists all active RAM partitions and their memory statistics:

RAM.LIST

RAM.INFO

Fetches deep inspection details for a specific RAM space:

RAM.INFO <space_name>

RAM.MERGE

Atomically moves all keys and values from src partition into dst partition:

RAM.MERGE <src_space> <dst_space>

RAM.DROP

Deletes an entire RAM space and instantly frees all associated memory:

RAM.DROP <space_name>

4. Python SDK Usage

from spedo import SpedoClient

client = SpedoClient(host="127.0.0.1", port=6380)

# 1. Create specialized RAM partitions
client.ram_create("ai_vectors", policy="vector_ai", maxmemory=256 * 1024 * 1024)
client.ram_create("staging_sessions", policy="ephemeral", maxmemory=64 * 1024 * 1024)

# 2. Inspect active spaces
spaces = client.ram_list()
for space in spaces:
    print(f"Space {space['name']}: {space['policy']} ({space['keys']} keys, {space['used_memory']} bytes)")

# 3. Merge staging partition into main partition
moved_keys = client.ram_merge("staging_sessions", "default")
print(f"Merged {moved_keys} keys into default space")

# 4. Drop space
client.ram_drop("staging_sessions")