mirror of
https://github.com/Viren070/AIOStreams.git
synced 2025-12-01 23:14:04 +01:00
fix(core): use structuredClone for cache item values to ensure immutability
fixes discover only option disappearing after refreshing
This commit is contained in:
@@ -152,7 +152,7 @@ export class Cache<K, V> {
|
||||
if (updateTTL) {
|
||||
item.lastAccessed = now;
|
||||
}
|
||||
return item.value;
|
||||
return structuredClone(item.value);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -167,7 +167,10 @@ export class Cache<K, V> {
|
||||
if (this.cache.size >= this.maxSize) {
|
||||
this.evict();
|
||||
}
|
||||
this.cache.set(key, new CacheItem<V>(value, Date.now(), ttl * 1000));
|
||||
this.cache.set(
|
||||
key,
|
||||
new CacheItem<V>(structuredClone(value), Date.now(), ttl * 1000)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user