mcpField
S
storage-sync

storage-sync

github.com/d-o-hubData & databases1343 installsUpdated today
Repository

About storage-sync

A skill for keeping a redb cache synchronized with durable Turso storage. It covers scheduled and recovery syncs, integrity checks, and handling partial or failed operations.

Key features

  1. 01Startup, scheduled, and manual sync
  2. 02Fetch episodes from Turso
  3. 03Update the redb cache
  4. 04Optional pattern and embedding sync
  5. 05Repair and resume error handling

Use cases

  1. 01Refresh the cache after startup
  2. 02Recover the cache after storage failures
  3. 03Resume a partially completed sync

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/d-o-hub/rust-self-learning-memory --skill storage-sync

After installing, type/storage-syncin Claude Code to confirm it loaded.

Details

From the project README

Storage Sync

Synchronize memories between Turso (durable) and redb (cache) storage layers.

When to Sync

  1. On startup - After system initialization
  2. Periodic - Scheduled background sync
  3. Cache staleness - When redb appears outdated
  4. Recovery - After storage failures
  5. Manual trigger - When explicitly requested

Sync Process

  1. Check connection health:

    turso_client.ping().await?;
    redb_env.check_integrity()?;
    
  2. Fetch latest from Turso:

    let episodes = turso_client
        .query("SELECT * FROM episodes ORDER BY timestamp DESC LIMIT ?")
        .bind(max_episodes_cache)
        .await?;
    
  3. Update redb cache:

    tokio::task::spawn_blocking(move || {
        let write_txn = redb.begin_write()?;
        let mut table = write_txn.open_table(EPISODES_TABLE)?;
        for episode in episodes {
            table.insert(episode.id.as_bytes(), episode.to_bytes())?;
        }
        write_txn.commit()?;
    });
    
  4. Sync patterns and embeddings if enabled

Configuration

pub struct SyncConfig {
    pub max_episodes_cache: usize,  // Default: 1000
    pub batch_size: usize,          // Default: 100
    pub sync_patterns: bool,        // Default: true
    pub sync_embeddings: bool,      // Default: true
}

Error Handling

ErrorHandling
Turso unavailableSkip sync, log warning, retry later
redb corruptionAttempt repair, rebuild from Turso
Partial syncTrack progress, resume from last point

Performance Tips

  • Batch small operations
  • Incremental sync (only changes)
  • Parallel fetch with Tokio
  • Write-ahead preparation

Validation

After sync, verify:

  • Episode count matches
  • Latest episodes present
  • Pattern counts consistent
  • No orphaned embeddings

Troubleshooting

IssueSolution
Slow syncsReduce cache size, increase batch
redb lock errorsUse dedicated write task
Memory pressureStream large results, smaller batches

Comments

Markdown supported