feat(db): expose EvictionConfig and relax default to favor search UX#4
Merged
feat(db): expose EvictionConfig and relax default to favor search UX#4
Conversation
これまでデフォルトが TTL 90 日 + per-account 50,000 件のハードな掃除だった
ため、ノートクライアント (例: notedeck) の差別化要素である「過去ノートを
ローカルキャッシュから一瞬で全文検索」 という UX を阻害していた。
変更点:
- 新規 `EvictionConfig { per_account_limit: Option<i64>, ttl_days: Option<i64> }`
を公開。`None` でその条件をスキップする設計。`#[cfg_attr(feature = "specta",
derive(specta::Type))]` 付きでアプリ側 (notedeck) からも型化して呼べる。
- `Database::open(path)` は後方互換性のため残し、デフォルト動作を「ほぼ永続」
に緩和:
- `per_account_limit: Some(1_000_000)` (実質暴走防止のみ)
- `ttl_days: None` (期限なし)
- 新規 `Database::open_with_eviction(path, EvictionConfig)` を追加。 アプリ側で
ユーザー設定値を渡す経路。
- 新規 `Database::cleanup_with_eviction(&EvictionConfig)` を追加。 起動時の
自動実行に加え、設定変更時に即時再 cleanup を行うためのフック。
- 旧 `cleanup_cache_inner` を `cleanup_with_eviction` に統合。
検索性を尊重するため CLI / daemon でもデフォルトでは「ほぼ永続」となる。
強い掃除が必要な利用者は明示的に `EvictionConfig` を渡す。
テスト:
- 既存 4 件を新 API に追従 (TTL only / cap only の組み合わせを明示)
- 新規 3 件追加: both disabled で no-op、TTL only で cap 無視、デフォルト値の検証
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
notes_cacheの eviction 設定をアプリ側から指定できるようEvictionConfigを公開し、デフォルトを「過去ノート検索」を阻害しない緩い値に変更する。Why
#3 で導入した eviction (TTL 90 日 + per-account 50,000 件) は、ノートクライアントの差別化要素である「過去ノートをローカルキャッシュから一瞬で全文検索 (FTS5)」という UX を阻害していた。
ヘビーユーザーは数年分の過去ノートをキャッシュとして保持したいケースが多く、デフォルトで 90 日でカットされるのは不利益。一方、無制限だと長期使用で青天井に肥大化するため、暴走防止の hard cap だけは残しつつデフォルトを緩める設計にする。
Changes
新規
EvictionConfig(specta feature 対応)API 拡張
Database::open(path)— 後方互換性のため維持。EvictionConfig::default()で動作。Database::open_with_eviction(path, config)— 新規。アプリ側がユーザー設定を渡す。Database::cleanup_with_eviction(&config)— 新規。設定変更時に即時再 cleanup できる。cleanup_cache_innerを統合・廃止。Noneのフィールドは該当 DELETE をスキップする設計で、両方Noneなら lock すら取らずに早期 return する。Test plan
cargo test --lib db::で 27 件 全 pass (新規 3 件: both-disabled no-op / TTL only / Default の検証)cargo build --features specta通過Migration impact
Database::open(path)の挙動変更 (デフォルトが大幅に緩い側へ)。長期運用 DB がディスク食いになる可能性はあるが、暴走防止 cap 1M はあるので致命ではない。明示的に厳しい掃除をしたい利用者はopen_with_evictionを呼ぶ。open_with_evictionを呼び、ユーザー設定をcacheEditorウィンドウから調整できるようにする予定。Related