Loading...
Loading...
Compare original and translation side by side
turso_client.ping().await?;
redb_env.check_integrity()?;let episodes = turso_client
.query("SELECT * FROM episodes ORDER BY timestamp DESC LIMIT ?")
.bind(max_episodes_cache)
.await?;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()?;
});turso_client.ping().await?;
redb_env.check_integrity()?;let episodes = turso_client
.query("SELECT * FROM episodes ORDER BY timestamp DESC LIMIT ?")
.bind(max_episodes_cache)
.await?;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()?;
});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
}pub struct SyncConfig {
pub max_episodes_cache: usize, // 默认值: 1000
pub batch_size: usize, // 默认值: 100
pub sync_patterns: bool, // 默认值: true
pub sync_embeddings: bool, // 默认值: true
}| Error | Handling |
|---|---|
| Turso unavailable | Skip sync, log warning, retry later |
| redb corruption | Attempt repair, rebuild from Turso |
| Partial sync | Track progress, resume from last point |
| 错误类型 | 处理方式 |
|---|---|
| Turso不可用 | 跳过同步,记录警告,稍后重试 |
| redb数据损坏 | 尝试修复,从Turso重建缓存 |
| 部分同步失败 | 跟踪同步进度,从断点恢复 |
| Issue | Solution |
|---|---|
| Slow syncs | Reduce cache size, increase batch |
| redb lock errors | Use dedicated write task |
| Memory pressure | Stream large results, smaller batches |
| 问题 | 解决方案 |
|---|---|
| 同步速度慢 | 减小缓存容量,增大批量处理大小 |
| redb锁错误 | 使用独立的写入任务 |
| 内存压力大 | 流式处理大结果集,减小批量大小 |