Sets a maximum age (minimum one day) for script storage values, after which they are deleted
À partir de
Ce script ne devrait pas être installé directement. C'est une librairie créée pour d'autres scripts. Elle doit être inclus avec la commande // @require https://update.greasyfork.org/scripts/562172/1731981/Temporary-Script-Storage.js
Storage set and accessed through an instance of this class will only live as long as the lifetime you set in the constructor, though it must be at least a day. After that time, it will expire and be deleted when sweepExpiredEntries() is called, which you can schedule with setInterval().
This library has no effect on script storage set directly through GM's setValue() the usual way. Such storage will behave normally.
Example usage:
const persistentStorage = new TTLStorage();
await persistentStorage.ready();
setInterval(() => persistentStorage.sweepExpiredEntries(), 1000 * 60 * 60 * 24);
persistentStorage.set("key1", "hello");
const msg = persistentStorage.get("key1");