fix: use unique storage key for morph info cache

This commit is contained in:
ggurdin 2026-01-27 14:16:09 -05:00
parent 6f65b08f74
commit 32218c0d87
No known key found for this signature in database
GPG key ID: A01CB41737CBB478

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;