The store key in local storage.
Either a number in milliseconds, or a Duration object
Log an error if we found an invalid object in the store. The invalid object is usually a string that cannot be parsed as JSON.
Optional
defaultValue: TSpecify a default value to use for the object. Defaults to undefined.
Simple local storage cache with support for auto-expiration. Note that this works in the browser context only because nodejs does not have local storage.
Create a cache item accessor object with auto-expiration. The value will always be stored as a string by applying JSON.stringify(), and will be returned in the same object type by applying JSON.parse().
In order to provide proper type-checking, please always specify the T type parameter. E.g. const item = storeItem("name", 10_000);