Merge pull request #5460 from pangeachat/5430-grammar-practice-explanation-language-not-change-when-swap-l1l2

fix: use unique storage key for morph info cache
This commit is contained in:
ggurdin 2026-01-27 14:16:41 -05:00 committed by GitHub
commit 63ba5a7d10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -52,7 +52,7 @@ class MorphInfoRepo {
final future = _safeFetch(accessToken, request);
// 4. Save to in-memory cache
_cache[request.hashCode.toString()] = _MorphInfoCacheItem(
_cache[request.storageKey] = _MorphInfoCacheItem(
resultFuture: future,
timestamp: DateTime.now(),
);
@ -67,7 +67,7 @@ class MorphInfoRepo {
MorphInfoRequest request,
MorphInfoResponse resultFuture,
) async {
final key = request.hashCode.toString();
final key = request.storageKey;
try {
await _storage.write(key, resultFuture.toJson());
_cache.remove(key); // Invalidate in-memory cache
@ -149,7 +149,7 @@ class MorphInfoRepo {
MorphInfoRequest request,
) {
final now = DateTime.now();
final key = request.hashCode.toString();
final key = request.storageKey;
// Remove stale entries first
_cache.removeWhere(
@ -173,7 +173,7 @@ class MorphInfoRepo {
static MorphInfoResponse? _getStored(
MorphInfoRequest request,
) {
final key = request.hashCode.toString();
final key = request.storageKey;
try {
final entry = _storage.read(key);
if (entry == null) return null;