Optional
cleanCheck for mismatches between data stored and access times every x milliseconds. Default: 300_000 = 5min
Optional
copyCopy values upon insertion.
The function used to copy values is structuredClone
,
unless a custom deepCopy function is provided.
If this is false and items are kept in memory (which can happen due to periodic persistence, see persistencePeriod, and/or due to memoryConfig), then the caller should avoid modifying objects that have been passed to the cache.
Default is false.
Optional
copyReturn copies of the stored values if they come from memory, so that the caller
can modify them without impacting the stored values
(there is no need to copy values restored from persistence).
The function used to copy values is structuredClone
,
unless a custom deepCopy function is provided.
If this is false and items are kept in memory (which can happen due to periodic persistence, see persistencePeriod, and/or due to memoryConfig), then the caller should avoid modifying objects returned from the cache.
Default is false.
Optional
databaseDefault: "LruIdbItemsCache"
Optional
deepOnly relevant if copyOnReturn is true or copyOnInsert is true.
By default it uses the global structuredClone
function.
Optional
evictionBatch eviction checks and operations. If this is set to a positive value, data eviction runs at most that often. In the meantime, the cache may grow beyond its specified capacity. If set to 0, items are deleted on every set operation if the cache is full, which may impede performance. Default: 60_000 = 1min
Optional
indexedDBMostly for testing. Default: globalThis.indexedDB
Optional
maxMaximum number of items to be kept in the store. Note that this is not enforced strictly, a clean up operation takes place regularly to purge the cache from old entries.
Default: 1000. Set to 0 to disable lru disposal and keep everything until deleted explicitly.
Optional
memoryKeep items in memory?
Optional
maxMaximum number of items in memory. Default: 100.
Optional
numDefault: maxItemsInMemory/4
Optional
numIn case the LruIdbConfig.maxItems threshold is violated, this number of entries will be removed from the cache.
Default: 50 or maxItems/4, whichever is smaller.
Optional
persistencePersist lru information every X milliseconds. If set to 0, periodic persistence is disabled. Default: 15_000 = 15s
Optional
tableDefault: "". The prefix will be prepended to "Items" and "AccessTimes" to generate the names for the two IndexedDB object stores used.
Optional
tableWhen using multiple caches with different table names but the same database in a single app, then it is more efficient to pass all the tables here, so they can be created right at the start. This is not strictly required, however, if a table for some cache is missing it will be created later, resulting in an IndexedDB version update.
Configuration parameters for LruIdb