Skip to content

Storage Tiering

MemoryLayer Enterprise supports a two-tier storage model. Hot tier memories are indexed for fast recall with full embedding support. Cold tier memories are moved to a compressed LEANN store for long-term retention at lower storage cost, with optional search during recall.

Tiering is opt-in per workspace: the cold tier is disabled until you enable it in the workspace’s tiering configuration.


Concepts

  • Hot tier: Active memories with full-text search, vector embeddings, and low-latency recall.
  • Cold tier: Archived memories stored in the LEANN cold tier. The hot embedding is dropped on archive and can be regenerated on restore.
  • Archival candidates: Memories eligible for cold storage based on importance, access count, and time since last access.
  • Cold-tier search: When both cold_tier_enabled and cold_tier_search_enabled are set for a workspace and the hot tier returns fewer results than requested, recall also searches the cold tier and merges the results.
  • Warmup: Promotion of frequently accessed cold memories back to the hot tier, run on demand with the warmup endpoint.

The /v1/tiering/* endpoints operate on the workspace of the authenticated request and require admin access (admin:read for reads, admin:write for changes).


View Storage Stats

Get a breakdown of hot and cold tier usage:

Terminal window
curl "$MEMORYLAYER_URL/v1/tiering/stats?include_candidates=true" \
-H "Authorization: Bearer $API_KEY"

Response:

{
"hot_memory_count": 15000,
"cold_memory_count": 45000,
"hot_storage_bytes": 52428800,
"cold_storage_bytes": 10485760,
"compression_ratio": 0.20,
"estimated_savings_bytes": 41943040,
"archival_candidates_count": 3200,
"document_storage_bytes": 0,
"documents_table_bytes": 0,
"document_pages_bytes": 0
}

compression_ratio is cold/hot storage (lower is better). Set include_candidates=false to skip candidate counting for faster responses. The document_* fields are populated only by the tenant-wide admin view (GET /v1/admin/tiering) and are 0 here.


Archive Memories

Move memories from the hot tier to the cold tier. You can archive specific memories by ID or let the system detect candidates.

Auto-detect candidates

Terminal window
curl -X POST "$MEMORYLAYER_URL/v1/tiering/archive" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"auto_detect": true,
"max_importance": 0.3,
"max_access_count": 2,
"older_than_days": 90,
"batch_size": 500
}'

Archive specific memories

Terminal window
curl -X POST "$MEMORYLAYER_URL/v1/tiering/archive" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"memory_ids": ["mem_001", "mem_002", "mem_003"]
}'

Archive request fields:

FieldDefaultDescription
memory_ids—Specific memory IDs to archive. Required unless auto_detect is true.
auto_detectfalseDetect candidates using the thresholds below
max_importanceserver default (0.3)Archive memories with importance at or below this value (0.0—1.0)
max_access_countserver default (5)Archive memories accessed at most this many times
older_than_daysserver default (90)Archive memories not accessed in at least this many days
batch_size100Maximum memories to archive in one operation (1—1000)

The response lists archived_count, failed_count, archived_memory_ids, and failed_memory_ids. Server defaults come from MEMORYLAYER_TIERING_MAX_IMPORTANCE, MEMORYLAYER_TIERING_MAX_ACCESS_COUNT, and MEMORYLAYER_TIERING_OLDER_THAN_DAYS.


Restore Memories

Bring memories back from the cold tier to the hot tier:

Terminal window
curl -X POST "$MEMORYLAYER_URL/v1/tiering/restore" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"memory_ids": ["mem_001", "mem_002"],
"regenerate_embeddings": true
}'

memory_ids is required (at least one). regenerate_embeddings (default true) recomputes vector embeddings on restore so the memories are fully searchable again. The response lists restored_count, failed_count, restored_memory_ids, and failed_memory_ids.


Warmup Cycles

Run a warmup cycle to promote frequently accessed cold memories:

Terminal window
curl -X POST "$MEMORYLAYER_URL/v1/tiering/warmup?access_threshold=5&limit=100" \
-H "Authorization: Bearer $API_KEY"
ParameterDefaultDescription
access_thresholdserver default (10, MEMORYLAYER_TIERING_WARMUP_ACCESS_THRESHOLD)Minimum cold-tier access count to trigger promotion
limit100Maximum memories to promote in one cycle

Tiering Configuration

Tiering configuration is stored per workspace (in the workspace’s settings.tiering). GET returns the effective configuration: server defaults overlaid with any workspace overrides.

View current config

Terminal window
curl "$MEMORYLAYER_URL/v1/tiering/config" \
-H "Authorization: Bearer $API_KEY"

Update config

Only the fields you send are changed.

Terminal window
curl -X PUT "$MEMORYLAYER_URL/v1/tiering/config" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"cold_tier_enabled": true,
"archival_age_days": 60,
"min_importance_threshold": 0.3,
"min_access_count_threshold": 5,
"warmup_access_threshold": 10,
"cold_tier_search_enabled": true
}'

Configuration fields:

FieldDefaultDescription
cold_tier_enabledfalseEnable the cold tier for this workspace
archival_age_days90Minimum days since last access before archival
min_importance_threshold0.3Maximum importance score for archival
min_access_count_threshold5Maximum access count for archival
archival_batch_size100Batch size for archival operations (1—1000)
warmup_access_threshold10Cold access count that triggers promotion
warmup_batch_size100Batch size for warmup operations (1—1000)
cold_tier_search_enabledfalseInclude the cold tier in recall when hot results are insufficient

The response also reports cold_retrieval_latency_target_ms (default 500), which is read-only through this API.


Automatic Archival

A recurring archival sweep can archive candidates automatically. It is off by default:

VariableDefaultDescription
MEMORYLAYER_TIERING_ARCHIVAL_ENABLEDfalseEnable the recurring sweep
MEMORYLAYER_TIERING_ARCHIVAL_INTERVAL_SEC86400Sweep interval
MEMORYLAYER_TIERING_ARCHIVAL_BATCH_SIZE100Maximum memories archived per workspace per sweep

The sweep only touches workspaces with cold_tier_enabled set. Before enabling it, gauge the impact with a dry run of the tenant-wide sweep:

Terminal window
curl -X POST "$MEMORYLAYER_URL/v1/admin/tiering/run" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"dry_run": true, "only_enabled": true, "batch_size": 100}'

dry_run defaults to true and reports per-workspace candidate counts without archiving. Set "dry_run": false to archive, "only_enabled": false to include workspaces without cold_tier_enabled, and max_workspaces to cap the number of workspaces processed. See Admin Dashboard.